What you will do
You will run the prepared expression in the playground above, change one input at a time, and explain the result. Start in CEL only, then repeat the same rule in CEL + JSON.
How it works
Operator precedence defines which operation runs first, but parentheses make the intended grouping visible to the reader. (subtotal - discount) * taxRate applies the discount before multiplication. subtotal - discount * taxRate multiplies first and therefore expresses a different calculation.
Read the prepared example
The CEL + JSON rule is:
(subtotal - discount) * taxRateIts input is:
{
"subtotal": 100,
"discount": 10,
"taxRate": 1.2
}The CEL only tab contains the values and the rule in one expression. The enabled cel.bind() extension keeps each name local to its final argument.
Evaluation step by step
- Parentheses produce
100.0 - 10.0 = 90.0. 90.0 * 1.2produces108.0.- The expression returns the calculated total.
Your task
- Run the original expression.
- Remove the parentheses and run
subtotal - discount * taxRate. - Explain why the second result is
88.0, then restore the original.
Expected observation: The original returns 108.0; the unparenthesized alternative returns 88.0.
Common mistake
Do not add parentheses randomly. Group operations according to the business calculation you can state in plain language.
Show the explanation
The subtraction inside parentheses runs first.
Knowledge check
Which operation runs first in the original expression?
Key takeaway
Use parentheses to communicate the calculation, not merely to satisfy the parser.
Sources
CEL-DEV— official CEL overview.CEL-LANG— official CEL language definition.CEL-GO-BIND— official documentation for the optionalcel.bind()extension used by the self-contained tab.