Documentation ¶
Index ¶
- type ObjectType
- func (o *ObjectType) Field(name string) (*types.FieldType, bool)
- func (o *ObjectType) FieldNames() ([]string, bool)
- func (o *ObjectType) HasTrait(trait int) bool
- func (o *ObjectType) Type() *types.Type
- func (o *ObjectType) TypeName() string
- func (o *ObjectType) Val(fields map[string]ref.Val) ref.Val
- type ObjectVal
- func (v *ObjectVal) CheckTypeNamesMatchFieldPathNames() error
- func (v *ObjectVal) ConvertToNative(typeDesc reflect.Type) (any, error)
- func (v *ObjectVal) ConvertToType(typeValue ref.Type) ref.Val
- func (v *ObjectVal) Equal(other ref.Val) ref.Val
- func (v *ObjectVal) IsZeroValue() bool
- func (v *ObjectVal) Type() ref.Type
- func (v *ObjectVal) Value() any
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ObjectType ¶
type ObjectType struct {
// contains filtered or unexported fields
}
ObjectType is the implementation of the Object type for use when compiling CEL expressions without schema information about the object. This is to provide CEL expressions with access to Object{} types constructors.
func NewObjectType ¶
func NewObjectType(name string) *ObjectType
NewObjectType creates a ObjectType by the given field name.
func (*ObjectType) Field ¶
func (o *ObjectType) Field(name string) (*types.FieldType, bool)
Field looks up the field by name. This is the unstructured version that allows any name as the field name. The returned field is of DynType type.
func (*ObjectType) FieldNames ¶
func (o *ObjectType) FieldNames() ([]string, bool)
func (*ObjectType) HasTrait ¶
func (o *ObjectType) HasTrait(trait int) bool
func (*ObjectType) Type ¶
func (o *ObjectType) Type() *types.Type
func (*ObjectType) TypeName ¶
func (o *ObjectType) TypeName() string
TypeName returns the name of this ObjectType.
type ObjectVal ¶
type ObjectVal struct {
// contains filtered or unexported fields
}
ObjectVal is the CEL Val for an object that is constructed via the Object{} in CEL expressions without schema information about the object.
func NewObjectVal ¶
NewObjectVal creates an ObjectVal by its ResolvedType and its fields.
func (*ObjectVal) CheckTypeNamesMatchFieldPathNames ¶
CheckTypeNamesMatchFieldPathNames transitively checks the CEL object type names of this ObjectVal. Returns all found type name mismatch errors. Children ObjectVal types under <field> or this ObjectVal must have type names of the form "<ObjectVal.TypeName>.<field>", children of that type must have type names of the form "<ObjectVal.TypeName>.<field>.<field>" and so on. Intermediate maps and lists are unnamed and ignored.
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.