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
Collection macros bind one temporary variable for each item. all(score, ...) returns true only if every score passes its predicate. exists(score, ...) returns true when at least one score passes. On an empty list, all() is true and exists() is false.
Read the prepared example
The CEL + JSON rule is:
scores.all(score, score >= 50.0) && scores.exists(score, score >= 90.0)Its input is:
{
"scores": [72, 94, 81]
}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
- Every score is at least
50.0. - The value
94.0is at least90.0. - Both macro results are true, so the combined result is
true.
Your task
- Run the example.
- Change
72to42and identify which macro fails. - Restore it, change
94to84, and identify the other failure.
Expected observation: A score below 50 fails all(); removing the only score at or above 90 fails exists().
Common mistake
The variable score exists only inside each macro predicate. It is not available after the macro call.
Show the explanation
all() returns true; exists() returns false.
Knowledge check
What do [].all(x, x > 0) and [].exists(x, x > 0) return?
Key takeaway
Use all() for a universal requirement and exists() for at least one match; consider empty collections explicitly.
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.