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
The conditional operator has the form condition ? valueWhenTrue : valueWhenFalse. CEL evaluates the condition first and then evaluates only the selected branch. The two branches should represent the same kind of result so that callers know what to expect.
Read the prepared example
The CEL + JSON rule is:
score >= passScore ? 'passed' : 'try again'Its input is:
{
"score": 72,
"passScore": 80
}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
72 >= 80returnsfalse.- CEL selects the expression after
:. - The final result is
"try again".
Your task
- Run the example and confirm the selected branch.
- Change
scoreto80and run again. - Remove one quote, observe the syntax error, and restore it.
Expected observation: A score of 80 selects "passed" because >= includes equality.
Common mistake
A syntax error prevents parsing before any input can be evaluated. A missing variable parses correctly but fails when the expression reads that value.
Show the explanation
No. Only the branch selected by the condition is evaluated.
Knowledge check
Is the false branch evaluated when the condition is true?
Key takeaway
Use ?: for a value selected by one condition, and separate syntax failures from input failures.
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.