Skip to content

Commit ada7864

Browse files
committed
refactor: make rules evaluation explicitly list all operators
This helps with future-proofing so that new operators don't automatically fallback to comparison evaluation.
1 parent e20986d commit ada7864

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

eppoclient/rules.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func evaluateCondition(subjectAttributes dictionary, condition condition) bool {
6060
return isOneOf(subjectValue, convertToStringArray(condition.Value))
6161
case "NOT_ONE_OF":
6262
return isNotOneOf(subjectValue, convertToStringArray(condition.Value))
63-
default:
63+
case "GTE", "GT", "LTE", "LT":
6464
// Attempt to coerce both values to float64 and compare them.
6565
subjectValueNumeric, isNumericSubjectErr := ToFloat64(subjectValue)
6666
conditionValueNumeric, isNumericConditionErr := ToFloat64(condition.Value)
@@ -84,6 +84,8 @@ func evaluateCondition(subjectAttributes dictionary, condition condition) bool {
8484

8585
// Fallback logic if neither numeric nor semver comparison is applicable.
8686
return false
87+
default:
88+
panic(fmt.Sprintf("unknown condition operator: %s", condition.Operator))
8789
}
8890
}
8991

0 commit comments

Comments
 (0)