Skip to content

Commit 08c80bf

Browse files
reynierozReyOrtiz
authored andcommitted
add ContainsStr built-in function
1 parent e4e90fe commit 08c80bf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

ast/BuiltInFunctions.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@
1515
package ast
1616

1717
import (
18-
"github.com/hyperjumptech/grule-rule-engine/logger"
1918
"math"
2019
"reflect"
20+
"slices"
2121
"strings"
2222
"time"
2323

24+
"github.com/hyperjumptech/grule-rule-engine/logger"
2425
"github.com/hyperjumptech/grule-rule-engine/pkg"
2526
)
2627

@@ -537,3 +538,8 @@ func (gf *BuiltInFunctions) Trunc(x float64) float64 {
537538

538539
return math.Trunc(x)
539540
}
541+
542+
// ContainsStr is a wrapper function for slices.Contains function for string
543+
func (gf *BuiltInFunctions) ContainsStr(s []string, v string) bool {
544+
return slices.Contains(s, v)
545+
}

0 commit comments

Comments
 (0)