Skip to content

Commit bbe11e0

Browse files
singhvikash11Vikash
and
Vikash
authored
feat: add match, split, contains function in expression evaluation (#141)
* feat: add match, split, contains function in expression evaluation * feat: add match, split, contains function in expression evaluation Co-authored-by: Vikash <[email protected]>
1 parent 4a1ca29 commit bbe11e0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

internal/evaluator/expression.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,19 @@ func (e Expression) String() string {
1717
return string(e)
1818
}
1919

20+
type ExprParam map[string]interface{}
21+
22+
func (m ExprParam) Split(s, sep string) []string {
23+
return strings.Split(s, sep)
24+
}
25+
2026
func (e Expression) EvaluateWithVars(params map[string]interface{}) (interface{}, error) {
2127
program, err := expr.Compile(e.String())
2228
if err != nil {
2329
return nil, fmt.Errorf("invalid expression: %w", err)
2430
}
2531

26-
env := make(map[string]interface{})
32+
env := make(ExprParam)
2733

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

0 commit comments

Comments
 (0)