Skip to content

Condition object

A rule's when is an object of operators. Every operator in one object must match (logical AND); for OR, write two rules. An omitted when always matches. A plain array is shorthand for {"in": [...]}.

{"when": {"gte": 21, "lte": 55}, "do": "review"}

The keys of when are operators, not field options. For the surrounding rule keys (do, to, max, at, …) see Rule object; for the keys inside a field spec see Field object.

Quick index

Operator Applies to In one line
eq · ne any Equal / not equal.
in · not_in any Membership in a list.
gt · gte · lt · lte numbers Numeric comparison.
len_eq · len_lt · len_lte · len_gt · len_gte strings, lists Length comparison.
contains lists, strings Contains an item / a substring.
match · not_match strings Regex matches the whole text.
eq_expr · ne_expr · lt_expr · lte_expr · gt_expr · gte_expr numbers Compare with a formula.
tol *_expr Tolerance (modifier).
confidence_lt · confidence_lte · confidence_gt · confidence_gte any with confidence Compare the field's confidence.

eq

Applies to: any · Matches: value equals the argument

{"when": {"eq": "active"}, "do": "review"}

Text is compared trimmed and case-insensitive (" ACTIVE " equals "active"). {"eq": null} matches null. A boolean is never equal to a number (true is not 1).

ne

Applies to: any · Matches: value differs from the argument

{"when": {"ne": "active"}, "do": "reject"}

Same comparison rules as eq (trimmed, case-insensitive). An enum-like "anything but the expected value" gate.

in

Applies to: any · Matches: value is in the argument list

{"when": {"in": ["low", "medium"]}, "do": "review"}

Membership uses the same rules as eq (null may appear in the list). An array written directly as when is shorthand for in:

{"when": ["low", "medium"], "do": "review"}   // same as {"in": ["low", "medium"]}

not_in

Applies to: any · Matches: value is not in the argument list

{"when": {"not_in": ["low"]}, "do": "end"}

lt

Applies to: numbers · Matches: value is less than the argument

{"when": {"lt": 21}, "do": "review"}

20 matches; 21 and 30 do not. Text, null and booleans never match.

lte

Applies to: numbers · Matches: value is less than or equal

{"when": {"lte": 40}, "do": "reject"}

40 and 12.5 match; 40.01 does not.

gt

Applies to: numbers · Matches: value is greater than the argument

{"when": {"gt": 55}, "do": "reject"}   // age gate

56 matches; 55 does not.

gte

Applies to: numbers · Matches: value is greater than or equal

{"when": {"gte": 3}, "do": "review"}

3 and 5 match; 2 does not. A range is two operators in one when:

{"when": {"gte": 21, "lte": 55}, "do": "review"}   // 21–55 inclusive

len_eq

Applies to: strings, lists · Matches: length equals the argument

{"when": {"len_eq": 16}, "do": "end"}

"3201456789012345" (16 chars) matches; "320145678901234" (15) does not. Length is measured in code on trimmed text, or on the number of list items.

len_lt

Applies to: strings, lists · Matches: length is less than

{"when": {"len_lt": 16}, "do": "reject"}

15 characters match; 16 characters do not.

len_lte

Applies to: strings, lists · Matches: length is less than or equal

{"when": {"len_lte": 3}, "do": "review"}

"abc" matches; "abcd" does not.

len_gt

Applies to: strings, lists · Matches: length is greater than

{"when": {"len_gt": 0}, "do": "review"}

["a"] matches; [] does not.

len_gte

Applies to: strings, lists · Matches: length is greater than or equal

{"when": {"len_gte": 1}, "do": "review"}

"x" matches; "" does not. Other types never match the length operators.

contains

Applies to: lists (an item), strings (a substring) · Matches: has it

{"when": {"contains": 500}, "do": "review"}     // list [404, 500] matches
{"when": {"contains": "cash"}, "do": "end"}     // "Paid in CASH" matches

List membership follows the eq rules (trimmed, case-insensitive). Text matching is a case-insensitive substring test. Other types never match.

match

Applies to: strings · Matches: regex matches the whole text

{"when": {"match": "\\d{16}"}, "do": "end"}

The regex must match the entire trimmed text (anchored). Escape backslashes in JSON ("\\d"). To search anywhere in the text, wrap the pattern: "(?is).*(approved|released).*". An invalid regex is rejected when the schema is parsed.

not_match

Applies to: strings · Matches: regex does not match the whole text

{"when": {"not_match": "\\d{16}"}, "do": "review"}

"3201-4567" matches; "3201456789012345" does not.

eq_expr

Applies to: numbers · Matches: value equals a formula over other fields

{"when": {"eq_expr": "subtotal + tax", "tol": 1}, "do": "end"}

The formula is the same safe expression language as compute: field names, numbers, + - * /, parentheses, abs, min, max, round. It is evaluated by code, never by the model. See tol for the tolerance.

ne_expr

Applies to: numbers · Matches: value differs from a formula

{"when": {"ne_expr": "subtotal - discount + tax", "tol": 1}, "do": "return", "max": 1}

The classic consistency check: the total should equal the formula. When it does not, return re-decodes once, then a second rule can flag a human.

lt_expr

Applies to: numbers · Matches: value is less than a formula

{"when": {"lt_expr": "api_price * 0.95"}, "do": "review"}

lte_expr

Applies to: numbers · Matches: value is less than or equal to a formula

{"when": {"lte_expr": "api_price"}, "do": "end"}

gt_expr

Applies to: numbers · Matches: value is greater than a formula

{"when": {"gt_expr": "api_price * 1.05"}, "do": "review"}

Useful to catch a web-search price that disagrees with a structured API: put the API value in an exposed call field and compare.

gte_expr

Applies to: numbers · Matches: value is greater than or equal to a formula

{"when": {"gte_expr": "minimum"}, "do": "review"}

How expression conditions behave

Referenced fields must run in the same or an earlier stage (else HTTP 400); they do not need to be depends_on, and they are checked to exist when the schema is parsed. If this value, any referenced value, or the formula result is null / not a number, or the formula divides by zero, the condition does not match.

tol

Applies to: *_expr operators · Modifier (not a condition by itself)

Absolute difference still treated as equal. Only valid together with an *_expr operator (otherwise HTTP 400).

{"when": {"ne_expr": "a + b", "tol": 1}, "do": "return"}

Without tol, values are compared exactly up to rounding noise (relative 1e-9). lte_expr / gte_expr also treat "within tol" as equal. Example: 108000 vs a formula giving 108900 with tol: 1 differs by 900 → ne_expr matches.

confidence_lt

Applies to: any field that has a confidence · Argument: number 0–1

{"when": {"confidence_lt": 0.9}, "do": "review"}

A field with confidence 0.77 matches. See Confidence and review.

confidence_lte

Applies to: any field that has a confidence

{"when": {"confidence_lte": 0.9}, "do": "review"}

A confidence of exactly 0.9 also matches.

confidence_gt

Applies to: any field that has a confidence

{"when": {"confidence_gt": 0.99}, "do": "end"}

A confidence of 0.9998 matches.

confidence_gte

Applies to: any field that has a confidence

{"when": {"confidence_gte": 0.99}, "do": "end"}

The argument must be a number between 0 and 1 (else HTTP 400). Fields without a confidence — free_form, compute and call — never match; using these operators on a free_form field is rejected when the schema is parsed.

Send doubt to review, not return

Re-running an uncertain field usually makes the model repeat its answer more confidently. Route hesitation straight to a human with review.