Documentation
¶
Overview ¶
Deprecated: This package is intended for older projects transitioning from OPA v0.x and will remain for the lifetime of OPA v1.x, but its use is not recommended. For newer features and behaviours, such as defaulting to the Rego v1 syntax, use the corresponding components in the github.com/open-policy-agent/opa/v1 package instead. See https://www.openpolicyagent.org/docs/latest/v0-compatibility/ for more information.
Package types declares data types for Rego values and helper functions to operate on these types.
Index ¶
- Variables
- func Arity(x Type) int
- func Compare(a, b Type) int
- func Contains(a, b Type) bool
- func Nil(a Type) bool
- func Sprint(x Type) string
- func Void(x Type) bool
- type Any
- type Array
- type Boolean
- type DynamicProperty
- type FuncArgs
- type Function
- type NamedType
- type Null
- type Number
- type Object
- type Set
- type StaticProperty
- type String
- type Type
Constants ¶
This section is empty.
Variables ¶
var A = NewAny()
A represents the superset of all types.
var B = NewBoolean()
B represents an instance of the boolean type.
var N = NewNumber()
N represents an instance of the number type.
var S = NewString()
S represents an instance of the string type.
Functions ¶
func Arity ¶ added in v0.34.0
Arity returns the number of arguments in the function signature or zero if x is not a function. If the type is unknown, this function returns -1.
Types ¶
type DynamicProperty ¶ added in v0.5.7
type DynamicProperty = v1.DynamicProperty
DynamicProperty represents a dynamic object property.
func NewDynamicProperty ¶ added in v0.5.7
func NewDynamicProperty(key, value Type) *DynamicProperty
NewDynamicProperty returns a new DynamicProperty object.
type FuncArgs ¶ added in v0.33.0
FuncArgs represents the arguments that can be passed to a function.
type Function ¶ added in v0.5.9
Function represents a function type.
func NewFunction ¶ added in v0.5.9
NewFunction returns a new Function object of the given argument and result types.
type NamedType ¶ added in v0.41.0
NamedType represents a type alias with an arbitrary name and description. This is useful for generating documentation for built-in functions.
type Object ¶
Object represents the object type.
func NewObject ¶
func NewObject(static []*StaticProperty, dynamic *DynamicProperty) *Object
NewObject returns a new Object type.
type StaticProperty ¶ added in v0.5.7
type StaticProperty = v1.StaticProperty
StaticProperty represents a static object property.
func NewStaticProperty ¶ added in v0.5.7
func NewStaticProperty(key interface{}, value Type) *StaticProperty
NewStaticProperty returns a new StaticProperty object.
type Type ¶
Type represents a type of a term in the language.
func Keys ¶
Keys returns the type of keys that can be enumerated for a. For arrays, the keys are always number types, for objects the keys are always string types, and for sets the keys are always the type of the set element.
func Or ¶
Or returns a type that represents the union of a and b. If one type is a superset of the other, the superset is returned unchanged.