Implement new function that splits filter rules

This commit is contained in:
ionutboangiu
2021-07-13 17:24:55 +03:00
committed by Dan Christian Bogos
parent 40b166893a
commit 263f73283b
2 changed files with 4 additions and 4 deletions

View File

@@ -191,7 +191,7 @@ func splitInlineFilter(rule string) (splt []string) {
// NewFilterFromInline parses an inline rule into a compiled Filter
func NewFilterFromInline(tenant, inlnRule string) (f *Filter, err error) {
ruleSplt := strings.SplitN(inlnRule, utils.InInFieldSep, 3)
ruleSplt := splitInlineFilter(inlnRule)
if len(ruleSplt) != 3 {
return nil, fmt.Errorf("inline parse error for string: <%s>", inlnRule)
}
@@ -335,7 +335,7 @@ func (fltr *FilterRule) CompileValues() (err error) {
if fltr.rsrElement, err = config.NewRSRParser(fltr.Element); err != nil {
return
} else if fltr.rsrElement == nil {
return fmt.Errorf("emtpy RSRParser in rule: <%s>", fltr.Element)
return fmt.Errorf("empty RSRParser in rule: <%s>", fltr.Element)
}
return
}

View File

@@ -5117,8 +5117,8 @@ func TestModelHelperAPItoFilterError(t *testing.T) {
}
_, err := APItoFilter(testStruct, "")
if err == nil || err.Error() != "emtpy RSRParser in rule: <>" {
t.Errorf("\nExpecting <emtpy RSRParser in rule: <>>,\n Received <%+v>", err)
if err == nil || err.Error() != "empty RSRParser in rule: <>" {
t.Errorf("\nExpecting <empty RSRParser in rule: <>>,\n Received <%+v>", err)
}
}