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
Conversion functions make a type change visible. int(rawScore) reads a valid numeric string and returns an integer; type(...) returns the CEL type value. Conversion is not validation magic: int("eighty-six") is invalid and evaluation returns an error.
Read the prepared example
The CEL + JSON rule is:
type(int(rawScore)) == int && int(rawScore) >= 80Its input is:
{
"rawScore": "86"
}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
int("86")produces the integer86.type(86) == intistrue.86 >= 80is alsotrue, so the final result istrue.
Your task
- Run the example.
- Change
rawScoreto"79"and run again. - Change it to
"high"and read the error before restoring it.
Expected observation: "79" returns false; "high" cannot be converted to int.
Common mistake
Repeated conversion is readable in a short demonstration but a host should normally provide correctly typed data. Use cel.bind() only when its extension is enabled.
Show the explanation
No. Invalid conversion is an evaluation error.
Knowledge check
Does int(rawScore) return 0 when the string is invalid?
Key takeaway
Convert explicitly and handle invalid source data as an error, not as an invented fallback value.
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.