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
A readable validation rule is a sequence of small boolean claims. This one requires non-empty text, at most 20 Unicode code points, and no slash. Short-circuit evaluation also means the expression can stop as soon as one required condition is false.
Read the prepared example
The CEL + JSON rule is:
name != '' && name.size() <= 20 && !name.contains('/')Its input is:
{
"name": "CEL guide"
}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
- The name is not empty.
- Its size is within 20 code points.
- It contains no slash, so all three conditions return
true.
Your task
- Run the valid name.
- Use an empty string, then a name containing
/. - Test a name longer than 20 characters and identify the failing condition each time.
Expected observation: Each invalid value returns false without requiring a special fallback.
Common mistake
Avoid compressing unrelated policy into one opaque regex. Separate checks let readers see the reason for rejection.
Show the explanation
No. A string containing only spaces is not equal to the empty string; trimming would require an enabled extension or host normalization.
Knowledge check
Does this rule trim whitespace before checking emptiness?
Key takeaway
Build validation from simple, named conditions and state any normalization that happens outside CEL.
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.