CH06-L04 · applied

From source text to a result

Connect syntax, types, and input data into the complete evaluation process.

General CELRuns hereDocumented
What will I learn?

You can identify what CEL checks and what the host application must define.

Where will I try it?

Directly below, in the browser playground.

What do I do?

Run both modes, compare where their values come from, then complete the task.

Try CEL · browser pilot

Try both ways to supply values

Define local values inside one CEL expression, or provide variables as JSON input. Everything runs in your browser.

CEL pilot subset
One self-contained CEL expressioncel.bind() gives a local name to a value and returns the result of the final expression.

cel.bind()cel.bind() is an optional official extension. It is not part of the core CEL language and may not be enabled by every host application.

Tip: press Ctrl/⌘ + Enter to run.
Result

Press Run CEL to evaluate the active example.

Pilot scope: literals, explicit conversions, local cel.bind() variables, JSON variables, lists, maps, presence, collection macros, core string checks, time values, arithmetic, comparisons, logic, and the conditional operator.

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 CEL host first parses source text, checks it against declared variables and types, and then evaluates it with concrete values. The host decides which variables, functions, macros, and optional extensions exist. CEL supplies the expression semantics; it does not discover application data by itself.

Read the prepared example

The CEL + JSON rule is:

type(request.priority) == string && request.priority in ['low', 'high']

Its input is:

{
  "request": {
    "priority": "high"
  }
}

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

  1. The host supplies request with a string member priority.
  2. The type check confirms string.
  3. Membership in the allowed list is true, so the final result is true.

Your task

  1. Run both modes.
  2. Change priority to "medium".
  3. Remove priority, inspect the error, and state whether it belongs to syntax, declarations, or runtime input.

Expected observation: "medium" is well typed but not allowed; a missing member is an input/presence problem, not a syntax error.

Common mistake

Do not assume an expression that runs in this playground will have the same variables or extensions in every CEL host. Confirm the target host configuration.

Show the explanation

The host application declares and supplies it; CEL only evaluates the expression against it.

Knowledge check

Who defines the meaning and availability of request?

Key takeaway

Separate language rules from host configuration: parse the expression, check names and types, then evaluate with supplied data.

Sources

  • CEL-DEV — official CEL overview.
  • CEL-LANG — official CEL language definition.
  • CEL-GO-BIND — official documentation for the optional cel.bind() extension used by the self-contained tab.