package
0.24.1
Repository: https://github.com/google/cel-go.git
Documentation: pkg.go.dev

# Functions

Abbrevs configures a set of simple names as abbreviations for fully-qualified names.
AlphaProtoAsDeclaration converts a v1alpha1.Decl value describing a variable or function into an EnvOption.
AlphaProtoAsValue converts between google.api.expr.v1alpha1.Value and ref.Val.
AstToCheckedExpr converts an Ast to an protobuf CheckedExpr value.
AstToParsedExpr converts an Ast to an protobuf ParsedExpr value.
AstToString converts an Ast back to a string if possible.
ASTValidators configures a set of ASTValidator instances into the target environment.
AttributePattern returns an AttributePattern that matches a top-level variable.
BinaryBinding provides the implementation of a binary overload.
CheckedExprToAst converts a checked expression proto message to an Ast.
CheckedExprToAstWithSource converts a checked expression proto message to an Ast, using the provided Source as the textual contents.
ClearMacros options clears all parser macros.
Constant creates an instances of an identifier declaration with a variable name, type, and value.
Container sets the container for resolving variable names.
ContextProtoVars uses the fields of the input proto.Messages as top-level variables within an Activation.
CostEstimatorOptions configure type-check time options for estimating expression cost.
CostLimit enables cost tracking and sets configures program evaluation to exit early with a "runtime cost limit exceeded" error if the runtime cost exceeds the costLimit.
CostTrackerOptions configures a set of options for cost-tracking.
CostTracking enables cost tracking and registers a ActualCostEstimator that can optionally provide a runtime cost estimate for any function calls.
CrossTypeNumericComparisons makes it possible to compare across numeric types, e.g.
CustomDecorator appends an InterpreterDecorator to the program.
CustomTypeAdapter swaps the default types.Adapter implementation with a custom one.
CustomTypeProvider replaces the types.Provider implementation with a custom one.
Declarations option extends the declaration set configured in the environment.
DeclareContextProto returns an option to extend CEL environment with declarations from the given context proto.
DefaultUTCTimeZone ensures that time-based operations use the UTC timezone rather than the input time's local timezone.
DisableDeclaration disables the function signatures, effectively removing them from the type-check environment while preserving the runtime bindings.
EagerlyValidateDeclarations ensures that any collisions between configured declarations are caught at the time of the `NewEnv` call.
EnableErrorOnBadPresenceTest enables error generation when a presence test or optional field selection is performed on a primitive type.
EnableHiddenAccumulatorName sets the parser to use the identifier '@result' for accumulators which is not normally accessible from CEL source.
EnableIdentifierEscapeSyntax enables identifier escaping (`) syntax for fields.
EnableMacroCallTracking ensures that call expressions which are replaced by macros are tracked in the `SourceInfo` of parsed and checked expressions.
EvalOptions sets one or more evaluation options which may affect the evaluation or Result.
ExcludeOverloads defines an OverloadSelector which deny-lists a set of overloads by their ids.
ExistsMacroExpander expands the input call arguments into a comprehension that returns true if any of the elements in the range match the predicate expressions: <iterRange>.exists(<iterVar>, <predicate>).
ExistsOneMacroExpander expands the input call arguments into a comprehension that returns true if exactly one of the elements in the range match the predicate expressions: <iterRange>.exists_one(<iterVar>, <predicate>).
ExprDeclToDeclaration converts a protobuf CEL declaration to a CEL-native declaration, either a Variable or Function.
ExprTypeToType converts a protobuf CEL type representation to a CEL-native type representation.
ExtendedValidations collects a set of common AST validations which reduce the likelihood of runtime errors.
FilterMacroExpander expands the input call arguments into a comprehension which produces a list which contains only elements which match the provided predicate expression: <iterRange>.filter(<iterVar>, <predicate>).
FormatCELType formats a cel.Type value to a string representation.
FormatType converts a type message into a string representation.
FromConfig produces and applies a set of EnvOption values derived from an env.Config object.
Function defines a function and overloads with optional singleton or per-overload bindings.
FunctionBinding provides the implementation of a variadic overload.
FunctionDecls provides one or more fully formed function declarations to be added to the environment.
Functions adds function overloads that extend or override the set of CEL built-ins.
GlobalMacro creates a Macro for a global function with the specified arg count.
Globals sets the global variable values for a given program.
GlobalVarArgMacro creates a Macro for a global function with a variable arg count.
HasMacroExpander expands the input call arguments into a presence test, e.g.
HomogeneousAggregateLiterals disables mixed type list and map literal values.
IncludeOverloads defines an OverloadSelector which allow-lists a set of overloads by their ids.
InterruptCheckFrequency configures the number of iterations within a comprehension to evaluate before checking whether the function evaluation has been interrupted.
Lib creates an EnvOption out of a Library, allowing libraries to be provided as functional args, and to be linked to each other.
Macros option extends the macro set configured in the environment.
MapMacroExpander expands the input call arguments into a comprehension that transforms each element in the input to produce an output list.
MaxConstantFoldIterations limits the number of times literals may be folding during optimization.
MemberOverload defines a new receiver-style overload (or member function) with an overload id, argument types, and result type.
NewActivation returns an activation based on a map-based binding where the map keys are expected to be qualified names used with ResolveName calls.
NewConstantFoldingOptimizer creates an optimizer which inlines constant scalar an aggregate literal values within function calls and select statements with their evaluated result.
NewCustomEnv creates a custom program environment which is not automatically configured with the standard library of functions and macros documented in the CEL spec.
NewEnv creates a program environment configured with the standard library of CEL functions and macros.
NewGlobalMacro creates a Macro for a global function with the specified arg count.
NewGlobalVarArgMacro creates a Macro for a global function with a variable arg count.
NewInlineVariable declares a variable name to be replaced by a checked expression.
NewInlineVariableWithAlias declares a variable name to be replaced by a checked expression.
NewInliningOptimizer creates and optimizer which replaces variables with expression definitions.
NewIssues returns an Issues struct from a common.Errors object.
NewIssuesWithSourceInfo returns an Issues struct from a common.Errors object with SourceInfo metatata which can be used with the `ReportErrorAtID` method for additional error reports within the context information that's inferred from an expression id.
NewReceiverMacro creates a Macro for a receiver function matching the specified arg count.
NewReceiverVarArgMacro creates a Macro for a receiver function matching a variable arg count.
NewStaticOptimizer creates a StaticOptimizer with a sequence of ASTOptimizer's to be applied to a checked expression.
NoVars returns an empty Activation.
OptimizeRegex provides a way to replace the InterpretableCall for regex functions.
OptionalTypes enable support for optional syntax and types in CEL.
OptionalTypesVersion configures the version of the optional type library.
Overload defines a new global overload with an overload id, argument types, and result type.
OverloadIsNonStrict enables the function to be called with error and unknown argument values.
OverloadOperandTrait configures a set of traits which the first argument to the overload must implement in order to be successfully invoked.
ParsedExprToAst converts a parsed expression proto message to an Ast.
ParsedExprToAstWithSource converts a parsed expression proto message to an Ast, using the provided Source as the textual contents.
ParserExpressionSizeLimit adjusts the number of code points the expression parser is allowed to parse.
ParserRecursionLimit adjusts the AST depth the parser will tolerate.
PartialVars returns a PartialActivation which contains variables and a set of AttributePattern values that indicate variables or parts of variables whose value are not yet known.
ProtoAsDeclaration converts a canonical celpb.Decl value describing a variable or function into an EnvOption.
ProtoAsValue converts between cel.expr.Value and ref.Val.
ReceiverMacro creates a Macro for a receiver function matching the specified arg count.
ReceiverVarArgMacro creates a Macro for a receiver function matching a variable arg count.
RefValueToValue converts between ref.Val and google.api.expr.v1alpha1.Value.
SingletonBinaryBinding creates a singleton function definition to be used with all function overloads.
SingletonBinaryImpl creates a singleton function definition to be used with all function overloads.
SingletonFunctionBinding creates a singleton function definition to be used with all function overloads.
SingletonFunctionImpl creates a singleton function definition to be used with all function overloads.
SingletonUnaryBinding creates a singleton function definition to be used for all function overloads.
StdLib returns an EnvOption for the standard library of CEL functions and macros.
StdLibSubset configures the standard library to use a subset of its functions and macros.
TypeDescs adds type declarations from any protoreflect.FileDescriptor, protoregistry.Files, google.protobuf.FileDescriptorProto or google.protobuf.FileDescriptorSet provided.
Types adds one or more type declarations to the environment, allowing for construction of type-literals whose definitions are included in the common expression built-in set.
TypeToExprType converts a CEL-native type representation to a protobuf CEL Type representation.
UnaryBinding provides the implementation of a unary overload.
ValidateComprehensionNestingLimit ensures that comprehension nesting does not exceed the specified limit.
ValidateDurationLiterals ensures that duration literal arguments are valid immediately after type-check.
ValidateHomogeneousAggregateLiterals checks that all list and map literals entries have the same types, i.e.
ValidateRegexLiterals ensures that regex patterns are validated after type-check.
ValidateTimestampLiterals ensures that timestamp literal arguments are valid immediately after type-check.
ValueAsAlphaProto converts between ref.Val and google.api.expr.v1alpha1.Value.
ValueAsProto converts between ref.Val and cel.expr.Value.
ValueToRefValue converts between google.api.expr.v1alpha1.Value and ref.Val.
Variable creates an instance of a variable declaration with a variable name and type.
VariableDecls configures a set of fully defined cel.VariableDecl instances in the environment.

# Constants

AnyKind represents a google.protobuf.Any type.
BoolKind represents a boolean type.
BytesKind represents a bytes type.
DoubleKind represents a double type.
DurationKind represents a CEL duration type.
DynKind represents a dynamic type.
HomogeneousAggregateLiteralExemptFunctions is the ValidatorConfig key used to configure the set of function names which are exempt from homogeneous type checks.
IntKind represents an integer type.
ListKind represents a list type.
MapKind represents a map type.
NullTypeKind represents a null type.
OpaqueKind represents an abstract type which has no accessible fields.
OptCheckStringFormat enables compile-time checking of string.format calls for syntax/cardinality.
OptExhaustiveEval causes the runtime to disable short-circuits and track state.
OptOptimize precomputes functions and operators with constants as arguments at program creation time.
OptPartialEval enables the evaluation of a partial state where the input data that may be known to be missing, either as top-level variables, or somewhere within a variable's object member graph.
OptTrackCost enables the runtime cost calculation while validation and return cost within evalDetails cost calculation is available via func ActualCost().
OptTrackState will cause the runtime to return an immutable EvalState value in the Result.
StringKind represents a string type.
StructKind represents a structured object with typed fields.
TimestampKind represents a a CEL time type.
TypeKind represents the CEL type.
TypeParamKind represents a parameterized type whose type name will be resolved at type-check time, if possible.
UintKind represents a uint type.

# Variables

AllMacro expands "range.all(var, predicate)" into a comprehension which ensures that all elements in the range satisfy the predicate.
AnyType represents the google.protobuf.Any type.
BoolType represents the bool type.
BytesType represents the bytes type.
DoubleType represents the double type.
DurationType represents the CEL duration type.
DynType represents a dynamic CEL type whose type will be determined at runtime from context.
ExistsMacro expands "range.exists(var, predicate)" into a comprehension which ensures that some element in the range satisfies the predicate.
ExistsOneMacro expands "range.exists_one(var, predicate)", which is true if for exactly one element in range the predicate holds.
FilterMacro expands "range.filter(var, predicate)" into a comprehension which filters elements in the range, producing a new list from the elements that satisfy the predicate.
HasMacro expands "has(m.f)" which tests the presence of a field, avoiding the need to specify the field as a string.
IntType represents the int type.
ListType creates an instances of a list type value with the provided element type.
MapFilterMacro expands "range.map(var, predicate, function)" into a comprehension which first filters the elements in the range by the predicate, then applies the transform function to produce a new list.
MapMacro expands "range.map(var, function)" into a comprehension which applies the function to each element in the range to produce a new list.
MapType creates an instance of a map type value with the provided key and value types.
NoMacros provides an alias to an empty list of macros.
NullableType creates an instance of a nullable type with the provided wrapped type.
NullType represents the type of a null value.
ObjectType creates a type references to an externally defined type, e.g.
OpaqueType creates an abstract parameterized type with a given name.
OptionalType creates an abstract parameterized type instance corresponding to CEL's notion of optional.
StandardMacros provides an alias to all the CEL macros defined in the standard environment.
StringType represents the string type.
TimestampType represents the time type.
TypeParamType creates a parameterized type instance.
TypeType represents a CEL type.
UintType represents a uint type.

# Structs

Ast representing the checked or unchecked expression, its source, and related metadata such as source position information.
Env encapsulates the context necessary to perform parsing, type checking, or generation of evaluable programs for different expressions.
EvalDetails holds additional information observed during the Eval() call.
InlineVariable holds a variable name to be matched and an AST representing the expression graph which should be used to replace it.
Issues defines methods for inspecting the error details of parse and check calls.
OptimizerContext embeds Env and Issues instances to make it easy to type-check and evaluate subexpressions and report any errors encountered along the way.
StaticOptimizer contains a sequence of ASTOptimizer instances which will be applied in order.

# Interfaces

ASTOptimizer applies an optimization over an AST and returns the optimized result.
ASTValidator defines a singleton interface for validating a type-checked Ast against an environment.
ASTValidatorConfigurer indicates that this object, currently expected to be an ASTValidator, participates in validator configuration settings.
ConfigurableASTValidator supports conversion of an object to an `env.Validator` instance used for YAML serialization.
Library provides a collection of EnvOption and ProgramOption values used to configure a CEL environment for a particular use case or with a related set of functionality.
LibraryAliaser generates a simple named alias for the library, for use during environment serialization.
LibrarySubsetter provides the subset description associated with the library, nil if not subset.
LibraryVersioner provides a version number for the library.
MacroExprHelper exposes helper methods for creating new expressions within a CEL abstract syntax tree.
MutableValidatorConfig provides mutation methods for querying and updating validator configuration settings.
Program is an evaluable view of an Ast.
SingletonLibrary refines the Library interface to ensure that libraries in this format are only configured once within the environment.
ValidatorConfig provides an accessor method for querying validator configuration state.

# Type aliases

Activation used to resolve identifiers by name and references by id.
ASTValidatorFactory creates an ASTValidator as configured by the input map.
ConfigOptionFactory declares a signature which accepts a configuration element, e.g.
ConstantFoldingOption defines a functional option for configuring constant folding.
EnvOption is a functional interface for configuring the environment.
Error type which references an expression id, a location within source, and a message.
EvalOption indicates an evaluation option that may affect the evaluation behavior or information in the output result.
FunctionOpt defines a functional option for configuring a function declaration.
Kind indicates a CEL type's kind which is used to differentiate quickly between simple and complex types.
Macro describes a function signature to match and the MacroExpander to apply.
MacroExpander converts a call and its associated arguments into a protobuf Expr representation.
MacroExprFactory assists with the creation of Expr values in a manner which is consistent the internal semantics and id generation behaviors of the parser and checker libraries.
MacroFactory defines an expansion function which converts a call and its arguments to a cel.Expr value.
OptionalTypesOption is a functional interface for configuring the strings library.
OverloadOpt is a functional option for configuring a function overload.
OverloadSelector selects an overload associated with a given function when it returns true.
PartialActivation extends the Activation interface with a set of UnknownAttributePatterns.
ProgramOption is a functional interface for configuring evaluation bindings and behaviors.
Source interface representing a user-provided expression.
StdLibOption specifies a functional option for configuring the standard CEL library.
Type holds a reference to a runtime type with an optional type-checked set of type parameters.