Math Expressions
Math expressions let you compute values inline on either side of a comparison, without needing to pre-compute fields in your data.
Syntax
Section titled “Syntax”Math expressions support full nested arithmetic:
<expression> <comparison> <expression>An expression can contain:
- properties
- literal numbers
+,-,*,/- natural-language aliases
- parentheses
| Operator | Accepted forms |
|---|---|
| addition | +, plus, added to |
| subtraction | -, minus, subtracted by |
| multiplication | *, times, multiplied by |
| division | /, divided by |
Precedence
Section titled “Precedence”The engine applies normal arithmetic precedence:
- parentheses
- multiplication and division
- addition and subtraction
This means multiplication happens before addition:
__subtotal__ of **Order** + __tax__ of **Order** * 2 is greater than 100Use parentheses when you want a different grouping:
(__subtotal__ of **Order** + __tax__ of **Order**) * 2 is greater than 100Addition
Section titled “Addition”__subtotal__ of **Order** + __tax__ of **Order** is greater than 100Aliases also work:
__subtotal__ of **Order** plus __tax__ of **Order** is greater than 100Interactive Example
Policy Rule
Test Data (JSON)
Mix a property with a literal:
Interactive Example
Policy Rule
Test Data (JSON)
Subtraction
Section titled “Subtraction”__balance__ of **Account** - __pending__ of **Account** is at least 0Interactive Example
Policy Rule
Test Data (JSON)
Multiplication
Section titled “Multiplication”__quantity__ of **Order** * __unit_price__ of **Order** is greater than 1000Interactive Example
Policy Rule
Test Data (JSON)
Division
Section titled “Division”__revenue__ of **Store** / __expenses__ of **Store** is greater than 1.5Interactive Example
Policy Rule
Test Data (JSON)
Nested Expressions
Section titled “Nested Expressions”You can nest expressions and put arithmetic on both sides of the comparison:
(__used__ of **Quota** + __buffer__ of **Quota**) * 2 is less than __limit__ of **Quota** * 3 - 1Interactive Example
Policy Rule
Test Data (JSON)
Combining with Other Conditions
Section titled “Combining with Other Conditions”Math expressions can be combined with and and or like any other condition:
Interactive Example
Policy Rule
Test Data (JSON)
Errors And Traces
Section titled “Errors And Traces”Every arithmetic step must resolve to numbers.
- Non-numeric operands return a type error that includes the failing expression.
- Division by zero returns an evaluation error that includes the full expression.
- Execution traces expose the evaluated left-hand expression path and the final right-hand value, so the UI can explain what was compared.
Example errors:
Arithmetic expression $.Applicant.status resolved to string, but numeric operands are requiredDivision by zero in arithmetic expression ($.Student.total / ($.Student.count - $.Student.count))Summary
Section titled “Summary”| Capability | Supported |
|---|---|
| literal numbers | yes |
| property references | yes |
| math on the left side | yes |
| math on the right side | yes |
| nested expressions | yes |
| parentheses | yes |
precedence (*// before +/-) | yes |
| Operator | Accepted forms | Example |
|---|---|---|
| addition | +, plus, added to | __subtotal__ of **Order** plus __tax__ of **Order** is greater than 50 |
| subtraction | -, minus, subtracted by | __balance__ of **Account** minus __reserved__ of **Account** is at least 0 |
| multiplication | *, times, multiplied by | __qty__ of **Order** times __price__ of **Order** is greater than 100 |
| division | /, divided by | __revenue__ of **Store** divided by __costs__ of **Store** is greater than 1 |