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": [...]}.
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
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
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
Membership uses the same rules as eq (null may appear in the list). An array
written directly as when is shorthand for in:
not_in¶
Applies to: any · Matches: value is not in the argument list
lt¶
Applies to: numbers · Matches: value is less than the argument
20 matches; 21 and 30 do not. Text, null and booleans never match.
lte¶
Applies to: numbers · Matches: value is less than or equal
40 and 12.5 match; 40.01 does not.
gt¶
Applies to: numbers · Matches: value is greater than the argument
56 matches; 55 does not.
gte¶
Applies to: numbers · Matches: value is greater than or equal
3 and 5 match; 2 does not. A range is two operators in one when:
len_eq¶
Applies to: strings, lists · Matches: length equals the argument
"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
15 characters match; 16 characters do not.
len_lte¶
Applies to: strings, lists · Matches: length is less than or equal
"abc" matches; "abcd" does not.
len_gt¶
Applies to: strings, lists · Matches: length is greater than
["a"] matches; [] does not.
len_gte¶
Applies to: strings, lists · Matches: length is greater than or equal
"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
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
"3201-4567" matches; "3201456789012345" does not.
eq_expr¶
Applies to: numbers · Matches: value equals a formula over other fields
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
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
lte_expr¶
Applies to: numbers · Matches: value is less than or equal to a formula
gt_expr¶
Applies to: numbers · Matches: value is greater than a formula
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
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).
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
A field with confidence 0.77 matches. See
Confidence and review.
confidence_lte¶
Applies to: any field that has a confidence
A confidence of exactly 0.9 also matches.
confidence_gt¶
Applies to: any field that has a confidence
A confidence of 0.9998 matches.
confidence_gte¶
Applies to: any field that has a confidence
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.