Skip to main content

Available Operators

Rule Engine JS includes 20+ built-in operators organized into 7 categories:

Comparison

6 operatorseq, neq, gt, gte, lt, lte

Logical

3 operatorsand, or, not

String

4 operatorscontains, startsWith, endsWith, regex

Array

2 operatorsin, notIn

Numeric

1 operatorbetween

Special

2 operatorsisNull, isNotNull

State

6 operatorschanged, changedBy, changedFrom, changedTo, increased, decreased

Quick Reference

Operator Syntax

All operators follow a consistent syntax pattern:

Single-Argument Operators

Two-Argument Operators

Multi-Argument Operators

Using Rule Helpers

The Rule Helpers API provides a more readable way to build rules:

Type Coercion

By default, operators perform type coercion for flexibility:
Use strict mode in production for type safety: createRuleEngine({ strict: true })

Operator Composition

Operators can be nested and combined for complex logic:

Custom Operators

Extend the engine with custom business logic:
Custom operators work seamlessly with all built-in operators and the Rule Helpers API.

Performance Considerations

Operator Order

Place faster operators first in and conditions to fail early

Avoid Deep Nesting

Deeply nested rules are harder to cache and slower to evaluate

Cache-Friendly Paths

Use consistent path names to maximize cache hits

Batch Similar Rules

Group related rules for better cache utilization

Next Steps

Comparison

Detailed comparison operators

Logical

Detailed logical operators

String

Detailed string operators

Array

Detailed array operators

State

Detailed state operators

Custom Operators

Create custom operators