What are Operators?
Operators are the building blocks of rules in Rule Engine JS. Each operator implements specific logic for comparing, transforming, or validating data.Rule Engine JS includes 20+ built-in operators organized into 7 categories, plus support for custom operators.
Operator Categories
Comparison
Compare values:
eq, neq, gt, gte, lt, lteLogical
Combine conditions:
and, or, notString
Text operations:
contains, startsWith, endsWith, regexArray
Array membership:
in, notInNumeric
Number operations:
betweenSpecial
Null checks:
isNull, isNotNullState
State changes:
changed, changedBy, changedFrom, changedTo, increased, decreasedQuick Reference
| Operator | Syntax | Description |
|---|---|---|
eq | { eq: ['age', 18] } | Equals comparison |
gt | { gt: ['score', 90] } | Greater than |
and | { and: [rule1, rule2] } | Logical AND |
or | { or: [rule1, rule2] } | Logical OR |
contains | { contains: ['name', 'John'] } | String contains |
in | { in: ['admin', 'roles'] } | Array membership |
between | { between: ['age', [18, 65]] } | Range check |
changed | { changed: ['status'] } | Value changed (stateful) |
Using Operators
- Direct JSON
- Rule Helpers
Custom Operators
Create custom operators for business-specific logic:Custom operators integrate seamlessly with built-in operators and rule helpers.
