Skip to content

At a glance#

Every function, macro, and operator available in all compliant CEL runtimes.

Functions#

String#

Function Description Example
s.contains(sub) True if s contains sub "alice@ex.com".contains("@")true
s.startsWith(prefix) True if s starts with prefix "Alice".startsWith("Al")true
s.endsWith(suffix) True if s ends with suffix "alice@ex.com".endsWith(".com")true
s.matches(regex) True if s matches RE2 pattern "hello".matches("^h.*o$")true

See Strings and numbers for contextual examples, Strings and bytes for full reference.

Size#

Function Types Example
size(x) string, bytes, list, map size("hello")5
x.size() string, bytes, list, map [1, 2, 3].size()3

Timestamp#

All timestamp functions accept an optional timezone string argument.

Function Description Example
t.getFullYear() Year t.getFullYear()2025
t.getMonth() Month (0-11) t.getMonth()11 (December)
t.getDate() Day of month (1-31) t.getDate()14
t.getDayOfMonth() Day of month (0-30) t.getDayOfMonth()13
t.getDayOfWeek() Day of week (0-6, 0 = Sunday) t.getDayOfWeek()0
t.getDayOfYear() Day of year (0-365) t.getDayOfYear()347
t.getHours() Hour (0-23) t.getHours()18
t.getMinutes() Minute (0-59) t.getMinutes()30
t.getSeconds() Second (0-59) t.getSeconds()0
t.getMilliseconds() Millisecond (0-999) t.getMilliseconds()0

See Timestamps and durations for contextual examples, Time for full reference.

Duration#

Function Description Example
d.getHours() Hours component duration("1h30m").getHours()1
d.getMinutes() Minutes component (0-59) duration("1h30m").getMinutes()30
d.getSeconds() Seconds component (0-59) duration("90s").getSeconds()30
d.getMilliseconds() Milliseconds component (0-999) duration("1.5s").getMilliseconds()500

Type conversion#

Function Input types Example
bool(x) bool, string bool("true")true
int(x) int, uint, double, string, timestamp, duration int("42")42
uint(x) int, uint, double, string uint(42)42u
double(x) int, uint, double, string double("3.14")3.14
string(x) int, uint, double, string, bytes, timestamp, duration string(42)"42"
bytes(x) string, bytes bytes("hello")b"hello"
timestamp(x) string, timestamp timestamp("2025-01-01T00:00:00Z")
duration(x) string, duration duration("1h30m")
dyn(x) any Erase static type
type(x) any type(42)int

See Type conversions and Type introspection for full reference.

Macros#

Macro Signature Description
has(x.f) has(field) -> bool True if field is set
e.all(x, p) list.all(var, predicate) -> bool True if all elements satisfy predicate
e.exists(x, p) list.exists(var, predicate) -> bool True if any element satisfies predicate
e.exists_one(x, p) list.exists_one(var, predicate) -> bool True if exactly one element satisfies predicate
e.filter(x, p) list.filter(var, predicate) -> list Elements satisfying predicate
e.map(x, t) list.map(var, transform) -> list Transform each element
e.map(x, p, t) list.map(var, predicate, transform) -> list Filter then transform

See Collections and Transforming data for contextual examples.

Operators#

Arithmetic#

Operator Types Example
-x int, double -5-5
x + y int, uint, double, string, bytes, list, timestamp/duration 1 + 23
x - y int, uint, double, timestamp/duration 5 - 32
x * y int, uint, double 3 * 412
x / y int, uint, double 10 / 33
x % y int, uint 10 % 31

See Arithmetic operators for full reference.

Comparison#

Operator Types Description
x == y any Equality
x != y any Inequality
x < y int, uint, double, string, bytes, timestamp, duration Less than
x <= y int, uint, double, string, bytes, timestamp, duration Less than or equal
x > y int, uint, double, string, bytes, timestamp, duration Greater than
x >= y int, uint, double, string, bytes, timestamp, duration Greater than or equal

See Strings and numbers for contextual examples, Comparison operators for full reference.

Logical#

Operator Types Description
!x bool Logical NOT
x && y bool Logical AND (short-circuits)
x || y bool Logical OR (short-circuits)
x ? y : z condition: bool, branches: any Conditional

See Logic and conditions for contextual examples, Logical operators and Conditional operator for full reference.

Membership#

Operator Types Description
x in y list, map Membership test
x[y] list, map, message Index or field access
x.y message, map Field or key access

See Collections for contextual examples, Lists and Maps for full reference.

See also#