Overview
Numeric operators perform numerical comparisons between values. Rule Engine JS provides four numeric comparison operators:gt
Greater than (>)
gte
Greater than or equal (≥)
lt
Less than (<)
lte
Less than or equal (≤)
Architecture
Source:src/operators/numeric.js | Tests: tests/unit/operators/numeric.test.js
Key Features
- Automatic type coercion - Converts string numbers to numeric values
- Dynamic comparison - Compare two field values or field to literal
- Strict mode - Prevent coercion when needed
- NaN handling - Proper error handling for invalid numbers
Syntax
All numeric operators follow the same pattern:Parameters
number | string
required
Left operand - field path or literal value
number | string
required
Right operand - field path or literal value
object
Operators
gt - Greater Than
gte - Greater Than or Equal
lt - Less Than
lte - Less Than or Equal
Common Use Cases
- Age Verification
- Price Range
- Score Validation
- Inventory Check
Type Coercion
Loose Mode (Default)
Strict Mode
Coercion Table
Error Handling
Non-Numeric Values
Non-Numeric Values
Missing Arguments
Missing Arguments
Undefined Fields
Undefined Fields
Quick Reference
Related Operators
Comparison
eq, neq
Special
between, isNull
Logical
and, or, not
Array
in, notIn
String
contains, startsWith
All Operators
Complete reference
