Skip to main content

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

Examples:

gte - Greater Than or Equal

Examples:

lt - Less Than

Examples:

lte - Less Than or Equal

Examples:

Common Use Cases

Type Coercion

Loose Mode (Default)

Strict Mode

Coercion Table

Error Handling

Quick Reference

Comparison

eq, neq

Special

between, isNull

Logical

and, or, not

Array

in, notIn

String

contains, startsWith

All Operators

Complete reference

API Reference