Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrEvalDenied = errors.New("eval: evaluation = false") ErrNoExpressions = errors.New("eval: no expressions") )
Functions ¶
This section is empty.
Types ¶
type Eval ¶
type Eval struct {
// contains filtered or unexported fields
}
func New ¶
Example ¶
package main
import (
"fmt"
"github.com/graphikDB/eval"
"strings"
)
func main() {
e, err := eval.New([]string{"this.email.endsWith('acme.com')"})
if err != nil {
fmt.Println(err.Error())
return
}
if err := e.AddExpression("this.name != ''"); err != nil {
fmt.Println(err.Error())
return
}
if err := e.Eval(eval.MapperFunc(func() map[string]interface{} {
return map[string]interface{}{
"name": "bob",
"email": "bob@acme.com",
}
}), eval.AllTrue); err != nil {
fmt.Println(err.Error())
return
}
fmt.Println(strings.Join(e.Expressions(), ","))
}
Output: this.email.endsWith('acme.com'),this.name != ''
func (*Eval) AddExpression ¶
func (*Eval) Expressions ¶
type MapperFunc ¶
type MapperFunc func() map[string]interface{}
func (MapperFunc) AsMap ¶
func (m MapperFunc) AsMap() map[string]interface{}
Click to show internal directories.
Click to hide internal directories.