From 08c80bf91bf11437ed35fe80776486f923a5b380 Mon Sep 17 00:00:00 2001 From: Reynier Ortiz Date: Wed, 24 Jan 2024 10:48:27 -0500 Subject: [PATCH] add ContainsStr built-in function --- ast/BuiltInFunctions.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ast/BuiltInFunctions.go b/ast/BuiltInFunctions.go index 86dc597a..75da4424 100755 --- a/ast/BuiltInFunctions.go +++ b/ast/BuiltInFunctions.go @@ -15,12 +15,13 @@ package ast import ( - "github.com/hyperjumptech/grule-rule-engine/logger" "math" "reflect" + "slices" "strings" "time" + "github.com/hyperjumptech/grule-rule-engine/logger" "github.com/hyperjumptech/grule-rule-engine/pkg" ) @@ -537,3 +538,8 @@ func (gf *BuiltInFunctions) Trunc(x float64) float64 { return math.Trunc(x) } + +// ContainsStr is a wrapper function for slices.Contains function for string +func (gf *BuiltInFunctions) ContainsStr(s []string, v string) bool { + return slices.Contains(s, v) +}