value

package
v0.0.0-...-c922539 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 23, 2024 License: Apache-2.0 Imports: 11 Imported by: 8

Documentation

Index

Constants

View Source
const (
	MustBeIntOp          = "mustBeInt"
	MustMatchAlternateOp = "mustMatchAlternate"
	MustMatchSchema      = "mustMatchSchema"
)
View Source
const (
	UndefinedPriority   = RightMergePriority(20)
	LoopControlPriority = RightMergePriority(10)
	DefaultedPriority   = RightMergePriority(0)
	TypeSchemaPriority  = RightMergePriority(5)
)
View Source
const (
	AddOp  = Operator("+")
	SubOp  = Operator("-")
	MulOp  = Operator("*")
	DivOp  = Operator("/")
	AndOp  = Operator("&&")
	OrOp   = Operator("||")
	LtOp   = Operator("<")
	LeOp   = Operator("<=")
	GtOp   = Operator(">")
	GeOp   = Operator(">=")
	EqOp   = Operator("==")
	NeqOp  = Operator("!=")
	NotOp  = Operator("!")
	MatOp  = Operator("=~")
	NmatOp = Operator("!~")
)
View Source
const (
	NullKind      = Kind("null")
	StringKind    = Kind("string")
	BoolKind      = Kind("bool")
	NumberKind    = Kind("number")
	ArrayKind     = Kind("array")
	ObjectKind    = Kind("object")
	FuncKind      = Kind("func")
	SchemaKind    = Kind("schema")
	UnionKind     = Kind("union")
	UndefinedKind = Kind("undefined")
)

Variables

View Source
var (
	True  = Boolean(true)
	False = Boolean(false)
)
View Source
var ErrMustMatchAlternate = errors.New("must match alternate")
View Source
var NoPosition = Position{}

Functions

func AssertKindsMatch

func AssertKindsMatch(left, right Value) error

func Compatible

func Compatible(val Value, kind Kind) bool

func Escape

func Escape(s string) string

func IsDefined

func IsDefined(val Value) bool

func IsLookupSupported

func IsLookupSupported(left Value) bool

func IsObjectLike

func IsObjectLike(v Value) bool

func IsSimpleKind

func IsSimpleKind(kind Kind) bool

IsSimpleKind returns true if the kind is a string, number, or bool.

func Keys

func Keys(right Value) ([]string, error)

func KeysIfSupported

func KeysIfSupported(right Value) ([]string, error)

func Match

func Match(pattern, value Value) (bool, error)

func NativeValue

func NativeValue(v Value) (any, bool, error)

func NewErrPosition

func NewErrPosition(pos Position, err error) error

func TargetCompatible

func TargetCompatible(schema Schema, target Value) bool

func ToArray

func ToArray(v Value) ([]any, error)

func ToBool

func ToBool(v Value) (bool, error)

func ToFloat

func ToFloat(v Value) (float64, error)

func ToInt

func ToInt(v Value) (int64, error)

func ToKind

func ToKind(v Value, kind Kind) (any, error)

func ToString

func ToString(v Value) (string, error)

func Unquote

func Unquote(s string) (string, error)

func WithCallPath

func WithCallPath(ctx context.Context) context.Context

func WithDataIndexPath

func WithDataIndexPath(ctx context.Context, idx int) context.Context

func WithDataKeyPath

func WithDataKeyPath(ctx context.Context, key string) context.Context

func WithIndexPath

func WithIndexPath(ctx context.Context, idx int) context.Context

func WithKeyPath

func WithKeyPath(ctx context.Context, key string) context.Context

Types

type Adder

type Adder interface {
	Add(right Value) (Value, error)
}

type AllUnaryOps

type AllUnaryOps interface {
	Adder
	Suber
	Noter
}

type Ander

type Ander interface {
	And(right Value) (Value, error)
}

type Array

type Array []Value

func NewArray

func NewArray(objs []any) Array

func (Array) Add

func (a Array) Add(right Value) (Value, error)

func (Array) Eq

func (a Array) Eq(right Value) (Value, error)

func (Array) GetUndefined

func (a Array) GetUndefined() Value

func (Array) Index

func (a Array) Index(idxValue Value) (Value, bool, error)

func (Array) IsDefined

func (a Array) IsDefined() bool

func (Array) Kind

func (a Array) Kind() Kind

func (Array) Len

func (a Array) Len() (Value, error)

func (Array) NativeValue

func (a Array) NativeValue() (any, bool, error)

func (Array) Slice

func (a Array) Slice(start, end int) (Value, bool, error)

func (Array) String

func (a Array) String() string

func (Array) ToValues

func (a Array) ToValues() []Value

type ArraySchema

type ArraySchema struct {
	Positions   []Position `json:"-"`
	Description string     `json:"description"`
	Valid       []Schema   `json:"valid"`
}

func (*ArraySchema) ImpliedDefault

func (n *ArraySchema) ImpliedDefault() (Value, bool, error)

func (*ArraySchema) Merge

func (a *ArraySchema) Merge(right *ArraySchema) (*ArraySchema, error)

func (*ArraySchema) Validate

func (a *ArraySchema) Validate(ctx context.Context, right Value) (Value, error)

type Boolean

type Boolean bool

func (Boolean) And

func (n Boolean) And(deferredRight Valuer) (Value, error)

func (Boolean) Eq

func (n Boolean) Eq(right Value) (Value, error)

func (Boolean) IsTrue

func (n Boolean) IsTrue() bool

func (Boolean) Kind

func (n Boolean) Kind() Kind

func (Boolean) NativeValue

func (n Boolean) NativeValue() (any, bool, error)

func (Boolean) Neq

func (n Boolean) Neq(right Value) (Value, error)

func (Boolean) Not

func (n Boolean) Not() (Value, error)

func (Boolean) Or

func (n Boolean) Or(deferredRight Valuer) (Value, error)

func (Boolean) String

func (n Boolean) String() string

type CallArgument

type CallArgument struct {
	Positional bool
	Self       bool
	Value      Value
}

type Caller

type Caller interface {
	Call(ctx context.Context, args []CallArgument) (Value, bool, error)
}

type Compatibler

type Compatibler interface {
	Compatible(kind Kind) bool
}

type Condition

type Condition func(val Value) (Value, error)

type Constraint

type Constraint struct {
	Op    string `json:"op,omitempty"`
	Right Value  `json:"right,omitempty"`
}

func MustMatchAlternate

func MustMatchAlternate() []Constraint

func (*Constraint) Check

func (c *Constraint) Check(ctx context.Context, left Value) error

type Constraints

type Constraints []Constraint

func (Constraints) Check

func (c Constraints) Check(ctx context.Context, left Value) error

type CustomConstraint

type CustomConstraint struct {
	CustomID          string
	CustomDescription string
	Checker           func(left Value) error
}

func (*CustomConstraint) Check

func (c *CustomConstraint) Check(left Value) error

func (*CustomConstraint) Description

func (c *CustomConstraint) Description() string

func (*CustomConstraint) ID

func (c *CustomConstraint) ID() string

func (*CustomConstraint) OpString

func (c *CustomConstraint) OpString() string

func (*CustomConstraint) RightNative

func (c *CustomConstraint) RightNative() (any, bool, error)

type Defaulter

type Defaulter interface {
	Default() (Value, bool, error)
}

type Deferred

type Deferred struct {
	Resolve      func() (Value, error)
	KindResolver func() Kind
}

func (Deferred) Add

func (d Deferred) Add(right Value) (Value, error)

func (Deferred) And

func (d Deferred) And(right Valuer) (Value, error)

func (Deferred) Call

func (d Deferred) Call(ctx context.Context, args []CallArgument) (Value, bool, error)

func (Deferred) Default

func (d Deferred) Default() (Value, bool, error)

func (Deferred) Div

func (d Deferred) Div(right Value) (Value, error)

func (Deferred) Eq

func (d Deferred) Eq(right Value) (Value, error)

func (Deferred) Ge

func (d Deferred) Ge(right Value) (Value, error)

func (Deferred) Gt

func (d Deferred) Gt(right Value) (Value, error)

func (Deferred) Index

func (d Deferred) Index(key Value) (Value, bool, error)

func (Deferred) Keys

func (d Deferred) Keys() ([]string, error)

func (Deferred) Kind

func (d Deferred) Kind() Kind

func (Deferred) Le

func (d Deferred) Le(right Value) (Value, error)

func (Deferred) Len

func (d Deferred) Len() (Value, error)

func (Deferred) LookupValue

func (d Deferred) LookupValue(key Value) (Value, bool, error)

func (Deferred) Lt

func (d Deferred) Lt(right Value) (Value, error)

func (Deferred) MarshalJSON

func (d Deferred) MarshalJSON() ([]byte, error)

func (Deferred) Mat

func (d Deferred) Mat(right Value) (Value, error)

func (Deferred) Match

func (d Deferred) Match(value Value) (bool, error)

func (Deferred) Merge

func (d Deferred) Merge(val Value) (Value, error)

func (Deferred) Mul

func (d Deferred) Mul(right Value) (Value, error)

func (Deferred) NativeValue

func (d Deferred) NativeValue() (any, bool, error)

func (Deferred) Neq

func (d Deferred) Neq(right Value) (Value, error)

func (Deferred) Nmat

func (d Deferred) Nmat(right Value) (Value, error)

func (Deferred) Not

func (d Deferred) Not() (Value, error)

func (Deferred) Or

func (d Deferred) Or(right Valuer) (Value, error)

func (Deferred) Slice

func (d Deferred) Slice(start, end int) (Value, bool, error)

func (Deferred) String

func (d Deferred) String() string

func (Deferred) Sub

func (d Deferred) Sub(right Value) (Value, error)

func (Deferred) ToFloat

func (d Deferred) ToFloat() (float64, error)

func (Deferred) ToInt

func (d Deferred) ToInt() (int64, error)

type DeferredAnder

type DeferredAnder interface {
	And(right Valuer) (Value, error)
}

type DeferredOrer

type DeferredOrer interface {
	Or(right Valuer) (Value, error)
}

type Diver

type Diver interface {
	Div(right Value) (Value, error)
}

type Entry

type Entry struct {
	Key   string
	Value Value
}

func Entries

func Entries(val Value) (result []Entry, _ error)

type Eqer

type Eqer interface {
	Eq(right Value) (Value, error)
}

type ErrMissingRequiredKeys

type ErrMissingRequiredKeys struct {
	SchemaPath Path
	DataPath   Path
	Keys       []string
}

func (*ErrMissingRequiredKeys) Error

func (e *ErrMissingRequiredKeys) Error() string

type ErrPosition

type ErrPosition struct {
	Position Position
	Err      error
}

func (*ErrPosition) Error

func (e *ErrPosition) Error() string

func (*ErrPosition) Pos

func (e *ErrPosition) Pos() Position

func (*ErrPosition) Unwrap

func (e *ErrPosition) Unwrap() error

type ErrSchemaViolation

type ErrSchemaViolation struct {
	DataPath   Path
	SchemaPath Path
	Key        string
	Err        error
}

func (*ErrSchemaViolation) Error

func (e *ErrSchemaViolation) Error() string

func (*ErrSchemaViolation) Unwrap

func (e *ErrSchemaViolation) Unwrap() error

type ErrUnknownField

type ErrUnknownField struct {
	SchemaPath Path
	DataPath   Path
	Key        string
}

func (*ErrUnknownField) Error

func (e *ErrUnknownField) Error() string

type ErrUnmatchedType

type ErrUnmatchedType struct {
	Position   Position
	Errs       []error
	Alternates []error
}

func (*ErrUnmatchedType) Error

func (e *ErrUnmatchedType) Error() string

func (*ErrUnmatchedType) Pos

func (e *ErrUnmatchedType) Pos() Position

func (*ErrUnmatchedType) Unwrap

func (e *ErrUnmatchedType) Unwrap() []error

type FuncSchema

type FuncSchema struct {
	Args         []ObjectSchemaField `json:"args"`
	ProfileNames Names               `json:"profileNames"`
	Returns      ToSchemaFunc        `json:"returns,omitempty"`
}

func (*FuncSchema) MarshalJSON

func (f *FuncSchema) MarshalJSON() ([]byte, error)

type Geer

type Geer interface {
	Ge(right Value) (Value, error)
}

type Gter

type Gter interface {
	Gt(right Value) (Value, error)
}

type Indexer

type Indexer interface {
	Index(key Value) (Value, bool, error)
}

type KeyList

type KeyList struct {
	// contains filtered or unexported fields
}

func (*KeyList) Add

func (k *KeyList) Add(keys ...string)

func (*KeyList) Get

func (k *KeyList) Get() []string

type Keyser

type Keyser interface {
	Keys() ([]string, error)
}

type Kind

type Kind string

func TargetKind

func TargetKind(v Value) Kind

type Leer

type Leer interface {
	Le(right Value) (Value, error)
}

type Lener

type Lener interface {
	Len() (Value, error)
}

type LookupValue

type LookupValue interface {
	LookupValue(key Value) (Value, bool, error)
}

type Lter

type Lter interface {
	Lt(right Value) (Value, error)
}

type Matcher

type Matcher interface {
	Match(value Value) (bool, error)
}

type Mater

type Mater interface {
	Mat(right Value) (Value, error)
}

type Merger

type Merger interface {
	Merge(val Value) (Value, error)
}

type Muler

type Muler interface {
	Mul(right Value) (Value, error)
}

type Name

type Name struct {
	Name        string
	Description string
}

type Names

type Names []Name

func (Names) Describe

func (n Names) Describe() (result Names)

type Neqer

type Neqer interface {
	Neq(right Value) (Value, error)
}

type Nmater

type Nmater interface {
	Nmat(right Value) (Value, error)
}

type Noter

type Noter interface {
	Not() (Value, error)
}

type Null

type Null struct {
}

func NewNull

func NewNull() *Null

func (*Null) Eq

func (n *Null) Eq(right Value) (Value, error)

func (*Null) Kind

func (n *Null) Kind() Kind

func (*Null) MarshalJSON

func (n *Null) MarshalJSON() ([]byte, error)

func (*Null) NativeValue

func (n *Null) NativeValue() (any, bool, error)

func (*Null) Neq

func (n *Null) Neq(right Value) (Value, error)

func (*Null) String

func (n *Null) String() string

type Number

type Number string

func (Number) Add

func (n Number) Add(right Value) (Value, error)

func (Number) Div

func (n Number) Div(right Value) (Value, error)

func (Number) Eq

func (n Number) Eq(right Value) (Value, error)

func (Number) Ge

func (n Number) Ge(right Value) (Value, error)

func (Number) Gt

func (n Number) Gt(right Value) (Value, error)

func (Number) Kind

func (n Number) Kind() Kind

func (Number) Le

func (n Number) Le(right Value) (Value, error)

func (Number) Lt

func (n Number) Lt(right Value) (Value, error)

func (Number) MarshalJSON

func (n Number) MarshalJSON() ([]byte, error)

func (Number) Mul

func (n Number) Mul(right Value) (Value, error)

func (Number) NativeValue

func (n Number) NativeValue() (any, bool, error)

func (Number) Neq

func (n Number) Neq(right Value) (Value, error)

func (Number) Sub

func (n Number) Sub(right Value) (Value, error)

func (Number) ToFloat

func (n Number) ToFloat() (float64, error)

func (Number) ToInt

func (n Number) ToInt() (int64, error)

type Object

type Object struct {
	Entries []Entry
}

func NewObject

func NewObject(data map[string]any) *Object

func (*Object) Add

func (n *Object) Add(right Value) (Value, error)

func (*Object) Eq

func (n *Object) Eq(right Value) (Value, error)

func (*Object) GetUndefined

func (n *Object) GetUndefined() Value

func (*Object) IsDefined

func (n *Object) IsDefined() bool

func (*Object) Keys

func (n *Object) Keys() ([]string, error)

func (*Object) Kind

func (n *Object) Kind() Kind

func (*Object) Len

func (n *Object) Len() (Value, error)

func (*Object) LookupValue

func (n *Object) LookupValue(key Value) (Value, bool, error)

func (*Object) MarshalJSON

func (n *Object) MarshalJSON() ([]byte, error)

func (*Object) Merge

func (n *Object) Merge(right Value) (Value, error)

func (*Object) NativeValue

func (n *Object) NativeValue() (any, bool, error)

func (*Object) String

func (n *Object) String() string

type ObjectFunc

type ObjectFunc struct {
	Self *Object
	Func Value
}

func (ObjectFunc) Call

func (o ObjectFunc) Call(ctx context.Context, args []CallArgument) (Value, bool, error)

func (ObjectFunc) Eq

func (o ObjectFunc) Eq(right Value) (Value, error)

func (ObjectFunc) Kind

func (o ObjectFunc) Kind() Kind

type ObjectMerge

type ObjectMerge func(left, right Value) (newValue Value, changed bool, _ error)

type ObjectSchema

type ObjectSchema struct {
	Positions    []Position          `json:"-"`
	AllowNewKeys bool                `json:"allowNewKeys"`
	Description  string              `json:"description"`
	Fields       []ObjectSchemaField `json:"fields"`
}

func (*ObjectSchema) ImpliedDefault

func (n *ObjectSchema) ImpliedDefault() (Value, bool, error)

func (*ObjectSchema) Merge

func (n *ObjectSchema) Merge(right *ObjectSchema) (*ObjectSchema, error)

func (*ObjectSchema) Validate

func (n *ObjectSchema) Validate(ctx context.Context, right Value, schemaPath Path) (Value, error)

type ObjectSchemaField

type ObjectSchemaField struct {
	Key         string `json:"key"`
	Match       bool   `json:"match"`
	Optional    bool   `json:"optional"`
	Description string `json:"description"`
	Schema      Schema `json:"schema"`
}

type Operator

type Operator string

type Orer

type Orer interface {
	Or(right Value) (Value, error)
}

type Path

type Path []PathElement

func GetDataPath

func GetDataPath(ctx context.Context) Path

func GetPath

func GetPath(ctx context.Context) Path

func (Path) Equals

func (p Path) Equals(right Path) bool

func (Path) MarshalJSON

func (p Path) MarshalJSON() ([]byte, error)

func (Path) String

func (p Path) String() string

type PathElement

type PathElement struct {
	Key   *string
	Index *int
	Call  bool
}

func (PathElement) Equals

func (p PathElement) Equals(right PathElement) bool

type Position

type Position struct {
	Filename string `json:"filename,omitempty"`
	Offset   int    `json:"offset,omitempty"`
	Line     int    `json:"line,omitempty"`
	Column   int    `json:"column,omitempty"`
}

func (Position) String

func (p Position) String() string

type RightMergePriority

type RightMergePriority int

type RightMerger

type RightMerger interface {
	RightMergePriority() RightMergePriority
	RightMerge(val Value) (Value, error)
}

type Schema

type Schema interface {
	Value
	Orer

	GetPositions() []Position
	Validate(ctx context.Context, v Value) (Value, error)
	TargetKind() Kind
	MergeType(right Schema) (Schema, error)
	DefaultWithImplicit(renderImplicit bool) (Value, bool, error)

	ValidArrayItems() []Schema
	GetPath() Path
}

type Slicer

type Slicer interface {
	Slice(start, end int) (Value, bool, error)
}

type String

type String string

func (String) Add

func (s String) Add(right Value) (Value, error)

func (String) Eq

func (s String) Eq(right Value) (Value, error)

func (String) Index

func (s String) Index(key Value) (Value, bool, error)

func (String) Kind

func (s String) Kind() Kind

func (String) Len

func (s String) Len() (Value, error)

func (String) Mat

func (s String) Mat(right Value) (Value, error)

func (String) Match

func (s String) Match(right Value) (bool, error)

func (String) NativeValue

func (s String) NativeValue() (any, bool, error)

func (String) Neq

func (s String) Neq(right Value) (Value, error)

func (String) Nmat

func (s String) Nmat(right Value) (Value, error)

type Suber

type Suber interface {
	Sub(right Value) (Value, error)
}

type Summary

type Summary struct {
	Types map[string]Schema `json:"types,omitempty"`
}

func Summarize

func Summarize(obj Schema) *Summary

type TargetCompatibler

type TargetCompatibler interface {
	TargetCompatible(target Value) bool
}

type ToFloater

type ToFloater interface {
	ToFloat() (float64, error)
}

type ToInter

type ToInter interface {
	ToInt() (int64, error)
}

type ToNative

type ToNative interface {
	NativeValue() (any, bool, error)
}

type ToSchemaFunc

type ToSchemaFunc func(context.Context) (Schema, bool, error)

type TypeSchema

type TypeSchema struct {
	Positions    []Position    `json:"-"`
	KindValue    Kind          `json:"kindValue"`
	Object       *ObjectSchema `json:"object"`
	Array        *ArraySchema  `json:"array"`
	FuncSchema   *FuncSchema   `json:"func"`
	Constraints  []Constraint  `json:"constraints"`
	Alternates   []Schema      `json:"alternates"`
	DefaultValue Value         `json:"defaultValue"`
	Path         Path          `json:"path"`
	Reference    bool          `json:"reference"`
	// contains filtered or unexported fields
}

func NewClosedObject

func NewClosedObject() *TypeSchema

func NewOpenObject

func NewOpenObject() *TypeSchema

func (*TypeSchema) And

func (n *TypeSchema) And(right Value) (Value, error)

func (*TypeSchema) Call

func (n *TypeSchema) Call(ctx context.Context, args []CallArgument) (Value, bool, error)

func (*TypeSchema) Default

func (n *TypeSchema) Default() (Value, bool, error)

func (*TypeSchema) DefaultWithImplicit

func (n *TypeSchema) DefaultWithImplicit(renderImplicit bool) (Value, bool, error)

func (*TypeSchema) Eq

func (n *TypeSchema) Eq(right Value) (Value, error)

func (*TypeSchema) Ge

func (n *TypeSchema) Ge(right Value) (Value, error)

func (*TypeSchema) GetPath

func (n *TypeSchema) GetPath() Path

func (*TypeSchema) GetPositions

func (n *TypeSchema) GetPositions() []Position

func (*TypeSchema) Gt

func (n *TypeSchema) Gt(right Value) (Value, error)

func (*TypeSchema) Keys

func (n *TypeSchema) Keys() (result []string, _ error)

func (*TypeSchema) Kind

func (n *TypeSchema) Kind() Kind

func (*TypeSchema) Le

func (n *TypeSchema) Le(right Value) (Value, error)

func (*TypeSchema) LookupValue

func (n *TypeSchema) LookupValue(key Value) (Value, bool, error)

func (*TypeSchema) Lt

func (n *TypeSchema) Lt(right Value) (Value, error)

func (*TypeSchema) Mat

func (n *TypeSchema) Mat(right Value) (Value, error)

func (*TypeSchema) Merge

func (n *TypeSchema) Merge(right Value) (Value, error)

func (*TypeSchema) MergeType

func (n *TypeSchema) MergeType(rightSchema Schema) (Schema, error)

func (*TypeSchema) NativeValue

func (n *TypeSchema) NativeValue() (any, bool, error)

func (*TypeSchema) Neq

func (n *TypeSchema) Neq(right Value) (Value, error)

func (*TypeSchema) Nmat

func (n *TypeSchema) Nmat(right Value) (Value, error)

func (*TypeSchema) Or

func (n *TypeSchema) Or(right Value) (Value, error)

func (*TypeSchema) RightMerge

func (n *TypeSchema) RightMerge(right Value) (Value, error)

func (*TypeSchema) RightMergePriority

func (n *TypeSchema) RightMergePriority() RightMergePriority

func (*TypeSchema) String

func (n *TypeSchema) String() string

func (*TypeSchema) TargetKind

func (n *TypeSchema) TargetKind() Kind

func (*TypeSchema) ValidArrayItems

func (n *TypeSchema) ValidArrayItems() (result []Schema)

func (*TypeSchema) Validate

func (n *TypeSchema) Validate(ctx context.Context, right Value) (Value, error)

type Undefined

type Undefined struct {
	Err error
	Pos Position
}

func (Undefined) Eq

func (u Undefined) Eq(v Value) (Value, error)

func (Undefined) IsDefined

func (u Undefined) IsDefined() bool

func (Undefined) Kind

func (u Undefined) Kind() Kind

func (Undefined) LookupValue

func (u Undefined) LookupValue(key Value) (Value, bool, error)

func (Undefined) Merge

func (u Undefined) Merge(val Value) (Value, error)

func (Undefined) NativeValue

func (u Undefined) NativeValue() (any, bool, error)

func (Undefined) RightMerge

func (u Undefined) RightMerge(val Value) (Value, error)

func (Undefined) RightMergePriority

func (u Undefined) RightMergePriority() RightMergePriority

func (Undefined) String

func (u Undefined) String() string

type Value

type Value interface {
	Kind() Kind
}

func Add

func Add(left, right Value) (Value, error)

func And

func And(left Value, right Valuer) (Value, error)

func BinaryOperation

func BinaryOperation(op Operator, left Value, deferredRight Valuer) (Value, error)

func Call

func Call(ctx context.Context, value Value, args ...CallArgument) (_ Value, _ bool, ret error)

func DefaultValue

func DefaultValue(v Value) (Value, bool, error)

func Div

func Div(left, right Value) (Value, error)

func Eq

func Eq(left, right Value) (Value, error)

func Ge

func Ge(left, right Value) (Value, error)

func GetUndefined

func GetUndefined(vals ...Value) Value

func Gt

func Gt(left, right Value) (Value, error)

func Index

func Index(left, key Value) (Value, bool, error)

func IsUndefined

func IsUndefined(vals ...Value) Value

IsUndefined is a small helper to check if any of the passed values are undefined

func Le

func Le(left, right Value) (Value, error)

func Len

func Len(left Value) (Value, error)

func Lookup

func Lookup(left, key Value) (Value, bool, error)

func Lt

func Lt(left, right Value) (Value, error)

func Mat

func Mat(left, right Value) (Value, error)

func Merge

func Merge(values ...Value) (result Value, err error)

func MergeObjectMerger

func MergeObjectMerger(left, right Value) (newValue Value, changed bool, _ error)

func MergeObjects

func MergeObjects(left, right Value, allowNewKeys bool, merger ObjectMerge) (merged Value, changed bool, _ error)

func Mul

func Mul(left, right Value) (Value, error)

func Neq

func Neq(left, right Value) (Value, error)

func NewDefault

func NewDefault(pos Position, v Value) Value

func NewMatchTypeWithDefault

func NewMatchTypeWithDefault(pos Position, v Value) Value

func NewValue

func NewValue(v any) Value

func Nmat

func Nmat(left, right Value) (Value, error)

func Not

func Not(right Value) (Value, error)

func Or

func Or(left Value, right Valuer) (Value, error)

func SchemaOr

func SchemaOr(left Schema, right Value) (Value, error)

func Slice

func Slice(left, start, end Value) (Value, bool, error)

func Sub

func Sub(left, right Value) (Value, error)

func ToValueArray

func ToValueArray(v Value) ([]Value, error)

func UnaryOperation

func UnaryOperation(op Operator, val Value) (Value, error)

func Validate

func Validate(ctx context.Context, schema Value, v Value) (Value, error)

type Valuer

type Valuer func() (Value, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL