Rule Validation Agent

The Rule Validation agent validates documents or data against a defined set of rules. Each rule is evaluated independently, and the agent returns a pass/fail result for each rule along with an overall verdict.

Use Cases

  • You need to check whether a document or dataset complies with a set of business rules.
  • A compliance workflow requires systematic rule-by-rule evaluation.
  • You want structured pass/fail output for auditing purposes.

Inputs

InputTypeDescription
documentDocumentThe document to validate against the rules.
textText(Alternative) Plain text to validate.
dataJSON(Alternative) Structured data to validate.

Outputs

OutputTypeDescription
overall_resultBooleantrue if all rules pass, false if any rule fails.
rule_resultsJSONPer-rule results with rule name, pass/fail, and explanation.

Configurations

ParameterDescriptionDefault
rulesList of rules to evaluate. Each rule has a name, description, and evaluation criteria.Required
fail_on_anyWhether to fail the overall result if any single rule fails.true

Deterministic Validation

The Rule Validation agent supports deterministic validation -- conditions that evaluate extracted data against rules without using an LLM. This is useful for exact checks like "does the PO amount match the invoice amount?" or "is the date within range?" You can define deterministic validations in two modes:

Condition Mode

A visual rule builder where you define conditions using extracted variables:

  • LHS (Data field) -- reference extracted fields using double curly braces: {{field_name}}. Chain methods on fields: {{field_name}}.method1(arg1).method2(arg2).
  • Operator -- compatible operators are shown based on the field type.
  • RHS (Value) -- a fixed value, another variable, or a static function like $now().

Examples:

{{PO Amount}} == {{Invoice Amount}}
{{Invoice Date}}.plus(30, "days") > $now()
{{Vendor Name}}.lower() == "acme corp"
{{PO Quantity}} >= {{Invoice Quantity}}

Currently, you can chain conditions with either ANDs or ORs, but not both in the same rule.

Supported operators by type:

TypeOperators
Boolean==, !=
Number==, !=, >, >=, <, <=, in, not in
String==, !=, substring, not substring, contains substring, does not contain substring, in, not in, substring in any of, substring not in any of
Datetime>, >=, <, <=, in, not in

Available functions:

FunctionReturnsDescription
$now()DatetimeCurrent date and time
.day()NumberDay of the month (1-31)
.month()NumberMonth of the year (1-12)
.year()NumberThe year
.hour()NumberHour of the day (0-23)
.plus(n, interval)DatetimeAdds a duration (seconds, minutes, hours, days, weeks, months, years)
.minus(n, interval)DatetimeSubtracts a duration
.plus(n) (number)NumberAdds n to the number
.minus(n) (number)NumberSubtracts n from the number
.lower()StringConverts to lowercase

Code Mode

For more complex validation logic, switch to the Code tab for a JavaScript editor:

  • Extracted fields are available as inputs.field_name.
  • For boolean rules: return "true" or "false" as a string.
  • For numerical rules: return a number.
  • Use log.info(), log.warning(), or log.error() for Show Work visibility.
// Boolean validation with tolerance
function main(inputs) {
 var poAmount = inputs.PO_Amount;
 var invoiceAmount = inputs.Invoice_Amount;

 if (poAmount === undefined || invoiceAmount === undefined) {
 log.warning("Missing amount fields");
 return "false";
 }

 var tolerance = 0.01;
 var passed = Math.abs(poAmount - invoiceAmount) <= tolerance;
 log.info(passed ? "Amounts match" : "Mismatch: PO=" + poAmount + ", Invoice=" + invoiceAmount);
 return passed ? "true" : "false";
}
// Numerical scoring
function main(inputs) {
 var score = 0;

 if (inputs.PO_Amount === inputs.Invoice_Amount) score += 40;
 if (inputs.PO_Quantity === inputs.Invoice_Quantity) score += 30;
 if (inputs.PO_Unit_Price === inputs.Invoice_Unit_Price) score += 30;

 log.info("Validation score: " + score);
 return score;
}

How to Use This Agent

Validate an insurance claim document against policy rules:

document_trigger -> rule_validation -> [pass] -> intelligent_actions("Approve claim")
 -> [fail] -> human_collaboration -> workflow_output

Last updated: Jul 3, 2026