Documentation ¶
Index ¶
Constants ¶
const ObjectTraits = traits.ContainerType
ObjectTraits is the bitmask that represents traits that an object should have.
const RootTypeReferenceName = "Object"
RootTypeReferenceName is the root reference that all type names should start with.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ObjectVal ¶
type ObjectVal struct {
// contains filtered or unexported fields
}
ObjectVal is the CEL Val for an object that is constructed via the object construction syntax.
func NewObjectVal ¶
NewObjectVal creates an ObjectVal by its TypeRef and its fields.
func (*ObjectVal) ConvertToNative ¶
ConvertToNative converts the object to map[string]any. All nested lists are converted into []any native type.
It returns an error if the target type is not map[string]any, or any recursive conversion fails.
func (*ObjectVal) ConvertToType ¶
ConvertToType supports type conversions between CEL value types supported by the expression language.
func (*ObjectVal) Equal ¶
Equal returns true if the `other` value has the same type and content as the implementing struct.
func (*ObjectVal) IsZeroValue ¶
IsZeroValue indicates whether the object is the zero value for the type. For the ObjectVal, it is zero value if and only if the fields map is empty.
type TypeRef ¶
type TypeRef interface { ref.Type // CELType wraps the TypeRef to be a type that is understood by CEL. CELType() *types.Type // Field finds the field by the field name, or false if the field is not known. // This function directly return a FieldType that is known to CEL to be more customizable. Field(name string) (*types.FieldType, bool) // Val creates an instance for the TypeRef, given its fields and their values. Val(fields map[string]ref.Val) ref.Val }
TypeRef refers an object type that can be looked up for its fields.
type TypeResolver ¶
type TypeResolver interface { // Resolve resolves the type by its name, starting with "Object" as its root. // The type that the name refers to must be an object. // This function returns false if the name does not refer to a known object type. Resolve(name string) (TypeRef, bool) }
TypeResolver resolves a type by a given name.