Skip to content

Commit be2c034

Browse files
committed
skipping the error empty return on some operators
1 parent a76f5b3 commit be2c034

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

‎rulesengine.go‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,8 @@ func resolveField(path string, data map[string]any) any {
139139
}
140140

141141
func evaluateRule(operator Operator, actual, expected any) (bool, any, error) {
142-
if actual == nil {
142+
if actual == nil && operator != IsNull && operator != NotExists &&
143+
operator != IsNotNull && operator != Exists {
143144
return false, actual, emptyValErr
144145
}
145146

@@ -229,16 +230,10 @@ func evaluateRule(operator Operator, actual, expected any) (bool, any, error) {
229230

230231
// ---------- Boolean ----------
231232
case IsTrue:
232-
if actual != true {
233-
return false, actual, nil
234-
}
235-
return true, nil, nil
233+
return actual == true, actual, nil
236234

237235
case IsFalse:
238-
if actual != false {
239-
return false, actual, nil
240-
}
241-
return true, nil, nil
236+
return actual == false, actual, nil
242237

243238
// ---------- Date ----------
244239
case Before, After:

0 commit comments

Comments
 (0)