Skip to content

Commit

Permalink
feat: add match, split, contains function in expression evaluation (#141
Browse files Browse the repository at this point in the history
)

* feat: add match, split, contains function in expression evaluation

* feat: add match, split, contains function in expression evaluation

Co-authored-by: Vikash <[email protected]>
  • Loading branch information
singhvikash11 and Vikash authored Mar 16, 2022
1 parent 4a1ca29 commit bbe11e0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion internal/evaluator/expression.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ func (e Expression) String() string {
return string(e)
}

type ExprParam map[string]interface{}

func (m ExprParam) Split(s, sep string) []string {
return strings.Split(s, sep)
}

func (e Expression) EvaluateWithVars(params map[string]interface{}) (interface{}, error) {
program, err := expr.Compile(e.String())
if err != nil {
return nil, fmt.Errorf("invalid expression: %w", err)
}

env := make(map[string]interface{})
env := make(ExprParam)

for _, c := range program.Constants {
if reflect.TypeOf(c).Kind() == reflect.String {
Expand Down

0 comments on commit bbe11e0

Please sign in to comment.