Skip to main content

Quick Start


Operator Structure


Simple Examples

isEven / isOdd

lengthEquals


Advanced Examples

inDateRange

matchesAny

haversineDistance


Validation

Add proper validation to operators.

Dynamic Operators

Create operators that generate other operators.

Async Operators

Rule Engine JS does not support async operators natively. All operators must be synchronous.
Workaround: Pre-fetch async data before evaluation.

Testing Custom Operators


Best Practices

Always check argument count and types.
Test with null, undefined, wrong types.
Operators should return true/false.
Name operators clearly (e.g., ‘isEven’, not ‘check’).
Add JSDoc comments explaining usage.
No async/await in operators.
Help users debug with clear error messages.

Complete Example


RuleEngine API

registerOperator() method

Built-in Operators

See all operators

Testing

Test your operators

Examples

Usage examples