Core Macros
Common Expression Language (CEL) provides powerful built-in macros that let you simplify handling lists, objects, strings, and logical conditions. With these macros, you can create concise, readable expressions, making it easier to manage complex logic.
Objects
Applies to both lists and maps.
Name | Return Type | Description |
---|---|---|
has | bool | Checks whether a field or property exists in a list or map. |
obj.all | bool | Checks if a predicate holds for all elements of a collection (either a list or a map). |
obj.exists | bool | Checks if a predicate holds for at least one element of a collection (either a list or a map). |
obj.exists_one | bool | Checks if a predicate holds for exactly one element of a collection (either a list or a map). |
obj.map | list | Transforms each element in a list or each key in a map by applying the given function. |
obj.map | list | Transforms each element in a list or each key in a map by applying a given predicate and transformation. |
obj.filter | list | Filters a list or map to include only elements that satisfy a condition. |
obj.size | int | Determines the number of entries in a map or elements in a list. |
has(field) -> bool
Checks whether a field or property exists in a list or map.
Example
Loading…
Checks if the x-custom-header
is present in the request headers.
obj.all(x,p) -> bool
Checks if a predicate p
holds for all elements of a collection obj
(either a list or a map).
Where x
is a variable name to be used in p
as a reference the element or key.
How it works
If any predicate for an element evaluates to false
, the entire expression will return false
. If all predicates evaluate to true
, the entire expression evaluates to true
. If one predicate fails (evaluates to false
), the all()
macro will stop evaluating the remaining elements and return false
immediately.
Errors in predicates are ignored.
Example
Loading…
Checks if all elements in the list [1, 2, 3]
are greater than 0
.