Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AllOf = Register(func(b ExprBuilder) func(ex ...Expression) Expression { return func(rules ...Expression) Expression { args := make([]any, len(rules)) for i := range rules { args[i] = rules[i] } return b.BuildExpression(args...) } }, &allOf{})
AllOf
Syntax
allOf(gt(1), lt(10))
View Source
var AnyOf = Register(func(b ExprBuilder) func(ex ...any) Expression { return func(ex ...any) Expression { return b.BuildExpression(ex...) } }, &anyOf{})
AnyOf
Syntax
anyOf(1, 2, 3)
View Source
var CharCount = Register(func(b ExprBuilder) func() Expression { return func() Expression { return b.BuildExpression() } }, &charCount{})
CharCount
Syntax
charCount()
View Source
var Elem = Register(func(b ExprBuilder) func(ex Expression) Expression { return func(ex Expression) Expression { return b.BuildExpression(ex) } }, &elem{})
Elem
Syntax
elem(eq(1))
View Source
var Eq = Register(func(b ExprBuilder) func(expect any) Expression { return func(expect any) Expression { return b.BuildExpression(expect) } }, &eq{})
Eq
Syntax
eq(1) eq(1.0) eq("x")
View Source
var Every = Register(func(b ExprBuilder) func(ex Expression) Expression { return func(ex Expression) Expression { return b.BuildExpression(ex) } }, &every{})
Every
Syntax
every( key(len(), gt(1)), elem(len(), gt(1)), )
View Source
var Get = Register(func(b ExprBuilder) func(fieldName string) Expression { return func(fieldName string) Expression { return b.BuildExpression(fieldName) } }, &get{})
Get
Syntax
get("x")
View Source
var Gt = Register(func(b ExprBuilder) func(expect any) Expression { return func(expect any) Expression { return b.BuildExpression(expect) } }, >{})
Gt
Syntax
gt(10)
View Source
var Gte = Register(func(b ExprBuilder) func(expect any) Expression { return func(expect any) Expression { return b.BuildExpression(expect) } }, >e{})
Gte
Syntax
gte(10)
View Source
var Key = Register(func(b ExprBuilder) func(ex Expression) Expression { return func(ex Expression) Expression { return b.BuildExpression(ex) } }, &key{})
Key
Syntax
key(eq(1))
View Source
var Len = Register(func(b ExprBuilder) func() Expression { return func() Expression { return b.BuildExpression() } }, &lenExpr{})
Len
Syntax
len()
View Source
var Lt = Register(func(b ExprBuilder) func(expect any) Expression { return func(expect any) Expression { return b.BuildExpression(expect) } }, <{})
Lt
Syntax
lt(10)
View Source
var Lte = Register(func(b ExprBuilder) func(expect any) Expression { return func(expect any) Expression { return b.BuildExpression(expect) } }, <e{})
Lte
Syntax
lte(10)
View Source
var Match = Register(func(b ExprBuilder) func(pattern string) Expression { return func(pattern string) Expression { return b.BuildExpression(pattern) } }, &match{})
Match
Syntax
match("[a-z]+")
View Source
var Not = Register(func(b ExprBuilder) func(ex ...Expression) Expression { return func(rules ...Expression) Expression { args := make([]any, len(rules)) for i := range rules { args[i] = rules[i] } return b.BuildExpression(args...) } }, ¬{})
Not
Syntax
not(gt(1))
View Source
var OneOf = Register(func(b ExprBuilder) func(ex ...any) Expression { return func(ex ...any) Expression { return b.BuildExpression(ex...) } }, &oneOf{})
OneOf
Syntax
oneOf(1, 2, 3)
View Source
var Pipe = Register(func(b ExprBuilder) func(ex ...any) Expression { return func(ex ...any) Expression { return b.BuildExpression(ex...) } }, &pipe{})
Pipe
Syntax
pipe(1, eq(1))
View Source
var Select = Register(func(b ExprBuilder) func(rules ...Expression) Expression { return func(rules ...Expression) Expression { args := make([]any, len(rules)) for i := range rules { args[i] = rules[i] } return b.BuildExpression(args...) } }, &selectExpr{})
Select
Syntax
select( when( pipe(get("x"), eq(1)), eq(2), ), eq(1), )
View Source
var Some = Register(func(b ExprBuilder) func(ex Expression) Expression { return func(ex Expression) Expression { return b.BuildExpression(ex) } }, &some{})
Every
Syntax
some( key(len(), gt(1)), elem(len(), gt(1)), )
View Source
var When = Register(func(b ExprBuilder) func(condition Expression, then Expression) Expression { return func(condition Expression, then Expression) Expression { return b.BuildExpression(condition, then) } }, &when{})
When
Syntax
when( pipe(get("x"), eq(1)), eq(2), )
Functions ¶
func Register ¶
func Register[T any](build func(b ExprBuilder) T, expr Expr) T
func WithValueGetter ¶
func WithValueGetter(ctx context.Context, getter ValueGetter) context.Context
Types ¶
type Expr ¶
type Expr interface { // Exec final exec Exec(ctx context.Context, input any) (any, error) String() string }
func From ¶
func From(expression Expression) (Expr, error)
type ExprBuilder ¶
type ExprBuilder interface {
BuildExpression(args ...any) Expression
}
type ExprCreator ¶
type Expression ¶
type Expression = []any
func Parse ¶
func Parse(b []byte) (Expression, error)
func ParseString ¶
func ParseString(s string) (Expression, error)
type ValueGetter ¶
func ValueGetterFromContext ¶
func ValueGetterFromContext(ctx context.Context) ValueGetter
func ValueGetterFunc ¶
func ValueGetterFunc(g func(name string) (any, bool)) ValueGetter
Source Files ¶
Click to show internal directories.
Click to hide internal directories.