Conditions & operators

Reference table for every operator in the CrowdControl language, with examples.

Operator table

OperatorLHSRHSResult
== !=anyanystring-coerced equality
< > <= >=numbernumbernumeric comparison
instringlist of stringsLHS appears in RHS
containslist or stringstringRHS appears in LHS
intersectslistlistLHS and RHS share at least one element
is_subsetlistlistevery element of LHS appears in RHS
matchesstringglobglob match (* wildcards)
matches_regexstringRE2 regexregex match
hasn/afield pathpath 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.