package types
import "github.com/open-policy-agent/opa/types"
Package types declares data types for Rego values and helper functions to operate on these types.
Index ¶
- Variables
- func Compare(a, b Type) int
- func Nil(a Type) bool
- func Sprint(x Type) string
- type Any
- func NewAny(of ...Type) Any
- func (t Any) Contains(other Type) bool
- func (t Any) Merge(other Type) Any
- func (t Any) String() string
- func (t Any) Union(other Any) Any
- type Array
- func NewArray(static []Type, dynamic Type) *Array
- func (t *Array) Dynamic() Type
- func (t *Array) Len() int
- func (t *Array) Select(pos int) Type
- func (t *Array) String() string
- type Boolean
- type Null
- type Number
- type Object
- func NewObject(static []*Property, dynamic Type) *Object
- func (t *Object) Dynamic() Type
- func (t *Object) Keys() []interface{}
- func (t *Object) Select(name interface{}) Type
- func (t *Object) String() string
- type Property
- type Set
- type String
- type Type
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 Compare ¶
Compare returns -1, 0, 1 based on comparison between a and b.
func Nil ¶
Nil returns true if a's type is unknown.
func Sprint ¶
Sprint returns the string representation of the type.
Types ¶
type Any ¶
type Any []Type
Any represents a dynamic type.
func NewAny ¶
NewAny returns a new Any type.
func (Any) Contains ¶
Contains returns true if t is a superset of other.
func (Any) Merge ¶
Merge return a new Any type that is the superset of t and other.
func (Any) String ¶
func (Any) Union ¶
Union returns a new Any type that is the union of the two Any types.
type Array ¶
type Array struct {
// contains filtered or unexported fields
}
Array represents the array type.
func NewArray ¶
NewArray returns a new Array type.
func (*Array) Dynamic ¶
Dynamic returns the type of the array's dynamic elements.
func (*Array) Len ¶
Len returns the number of static array elements.
func (*Array) Select ¶
Select returns the type of element at the zero-based pos.
func (*Array) String ¶
type Boolean ¶
type Boolean struct{}
Boolean represents the boolean type.
func NewBoolean ¶
func NewBoolean() Boolean
NewBoolean returns a new Boolean type.
func (Boolean) String ¶
type Null ¶
type Null struct{}
Null represents the null type.
func NewNull ¶
func NewNull() Null
NewNull returns a new Null type.
func (Null) String ¶
type Number ¶
type Number struct{}
Number represents the number type.
func NewNumber ¶
func NewNumber() Number
NewNumber returns a new Number type.
func (Number) String ¶
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
Object represents the object type.
func NewObject ¶
NewObject returns a new Object type.
func (*Object) Dynamic ¶
Dynamic returns the type of the object's dynamic elements.
func (*Object) Keys ¶
func (t *Object) Keys() []interface{}
Keys returns the keys of the object's static elements.
func (*Object) Select ¶
Select returns the type of the named property.
func (*Object) String ¶
type Property ¶
type Property struct { Key interface{} Value Type }
Property represents a static object property.
func NewProperty ¶
NewProperty returns a new Property object.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set represents the set type.
func NewSet ¶
NewSet returns a new Set type.
func (*Set) String ¶
type String ¶
type String struct{}
String represents the string type.
func NewString ¶
func NewString() String
NewString returns a new String type.
func (String) String ¶
type Type ¶
type Type interface { String() string }
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.
func Select ¶
Select returns a property or item of a.
func TypeOf ¶
func TypeOf(x interface{}) Type
TypeOf returns the type of the Golang native value.
func Values ¶
Values returns the type of values that can be enumerated for a.
Source Files ¶
- Version
- v0.5.0
- Published
- Jul 5, 2017
- Platform
- linux/amd64
- Imports
- 5 packages
- Last checked
- 2 minutes ago –
Tools for package owners.