Skip to main content

Rule Syntax & JSON Schemas

Helix rules are defined as standard JSON documents containing 4 top-level attributes: name, version, expression, and inputSchema.


JSON Rule Structure​

{
"name": "DiscountEligibilityRule",
"version": "1.2.0",
"expression": "cartTotal >= 100.0 && (isMember == true || couponsApplied > 0)",
"inputSchema": {
"cartTotal": "double",
"isMember": "boolean",
"couponsApplied": "int"
}
}

Attribute Specifications​

FieldTypeDescription
nameStringUnique identifier for the rule. Used for caching and ClassLoader mapping.
versionStringSemantic version string (major.minor.patch). Enables versioned caching and hot reloads.
expressionStringInfix boolean expression evaluated at runtime against the input context.
inputSchemaObjectMap of variable names to their expected primitive or object Java types.

Supported Data Types​

Schema Type NameJVM Java TypeDefault ValueExample Literals
"int"int / java.lang.Integer042, -10, 1000
"long"long / java.lang.Long0L5000000000L
"double"double / java.lang.Double0.03.14159, 100.0
"boolean"boolean / java.lang.Booleanfalsetrue, false
"String"java.lang.Stringnull"US", "ACTIVE", "GOLD"

Supported Operators​

Relational Operators​

  • Greater than: >, >=
  • Less than: <, <=
  • Equality: ==, !=

Logical Operators​

  • Logical AND: &&
  • Logical OR: ||
  • Logical NOT: !
  • Parentheses for grouping: ( )

Arithmetic Operators​

  • Addition & Subtraction: +, -
  • Multiplication & Division: *, /
  • Modulo: %

Context Evaluation Data Format​

When evaluating a rule, provide matching key-value pairs matching the inputSchema:

examples/rules/context.json
{
"cartTotal": 125.50,
"isMember": true,
"couponsApplied": 1
}