Conditions & operators
Reference table for every operator in the CrowdControl language, with examples.
Operator table
| Operator | LHS | RHS | Result |
|---|---|---|---|
== != | any | any | string-coerced equality |
< > <= >= | number | number | numeric comparison |
in | string | list of strings | LHS appears in RHS |
contains | list or string | string | RHS appears in LHS |
intersects | list | list | LHS and RHS share at least one element |
is_subset | list | list | every element of LHS appears in RHS |
matches | string | glob | glob match (* wildcards) |
matches_regex | string | RE2 regex | regex match |
has | n/a | field path | path exists in document |
Numeric coercion
When a comparison expects a number, strings that look like numbers are coerced via strconv.ParseFloat. This means "42" == 42 is true (both sides are string-coerced for equality) and "42" > 10 is true (numeric comparison coerces).
Absent fields
If any segment of a dotted path is missing or non-map, the path resolves to "absent". Comparing an absent field to anything is false; has returns false; count() returns 0; len() returns 0.
Short-circuit evaluation
In normal evaluation, conditions short-circuit: if any condition in a rule body is false, later conditions aren't evaluated. In explain mode, all conditions are evaluated so the trace is complete.