Strings and numbers#
CEL inspects and compares strings and numbers with built-in functions and operators. Examples on this page use this message:
{
"name": "Alice",
"roles": ["admin", "editor", "viewer"],
"age": 30,
"email": "alice@example.com",
"created": timestamp("2025-12-14T00:00:00Z"),
"email_verified": timestamp("2025-12-14T18:30:00Z")
}
String functions#
endsWith() checks if a string ends with a given suffix.
contains() checks for a substring anywhere in the string.
startsWith() checks the beginning of a string.
matches() tests a RE2 regular expression.
size() returns the number of Unicode code points.
Use size() to check that a field is non-empty.
String concatenation#
+ joins strings together.
Numeric comparisons#
Standard comparison operators work on numbers.
Check a range by combining two comparisons.
Combining checks#
String functions and numeric comparisons combine naturally with && and ||.
See also#
- Strings and bytes - String literals, escape sequences, bytes, and conversion
- Comparison operators - Equality and ordering for all types
- Booleans and numbers - Boolean logic and numeric types
- At a glance - Every function, macro, and operator