Skip to main content

Rules

Rules Syntax

A rule is a string that represents a boolean expression. It should be in the format <variable> <operator> <value>. Additionally, rules can be combined in the following format <rule> <boolean operator> <rule>. Quotes inside the rules need to be escaped appropriately.

The following operators are supported:

Boolean operatorMeaningExample
=, ==, isequal tocountry = "US"
<, ltless thanage < 50
>, gtgreater thanage > 20
<=less than or equalage <= 50
>=greater than or equalage >= 20
inpresent in list of itemscountry in ["US", "FR"]
inRangepresent in range of valuesage inRange (20, 50)
!, notboolean "not"!(country = "US")
|, ||, orboolean "or"country = "US" or age < 50
&, &&, andboolean "and"age > 20 & age < 50
containsstring containsuser-agent contains "Chrome"
startsWithstring startsWithuser-agent startsWith "Chrome"
endsWithstring endsWithuser-agent endsWith "81"
containsAnyarray contains any elementsids containsAll [1, 2, 3]
containsAllarray contains all elementsids containsAny [1, 2, 3]
Geo OperatorMeaningExample
near byvalue near coordinateuserCoordinates near [41.176296, -8.596050] by 30 km
Date OperatorMeaningExample
aftertimestamp is after x dayslastPurchase after 7 days ago
beforetimestamp is before x dayslastPurchase before 3 days ago
betweentimestamp is between x and y dayslastPurchase between 3 and 7 days ago
FunctionMeaningExample
oneOfgroup of boolean "or"soneOf(country = "US", age < 50)
allOfgroup of boolean "and"sandOf(age > 20, age < 50)
isDefinedreturns true if a variable is definedisDefined(country)
existsfirst-order "or" operatorexists(c:countries, c == "US")
forAllfirst-order "and" operatorforAll(p:purchases, p > 50)