From 9f52550a960ae51bee8305765b11fc6b24aae6cc Mon Sep 17 00:00:00 2001 From: Brooke Bryan Date: Mon, 28 Oct 2024 17:16:25 +0000 Subject: [PATCH] Additional operator validation (#223) --- selector/predicates.go | 2 +- utils/validate_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/selector/predicates.go b/selector/predicates.go index 281d43a..4d1e295 100644 --- a/selector/predicates.go +++ b/selector/predicates.go @@ -30,7 +30,7 @@ const ( type Predicate struct { Key Key `json:"key" yaml:"key" validate:"predicate-key"` - Operator PredicateOperator `json:"operator" yaml:"operator" validate:"oneof=Equal NotEqual In NotIn Exists DoesNotExists Gt Lt Like InLike"` + Operator PredicateOperator `json:"operator" yaml:"operator" validate:"oneof=Equal NotEqual In NotIn Exists DoesNotExists Gt Lt Like InLike NotLike NotInLike"` Conversion OperatorConversion `json:"conversion" yaml:"conversion" validate:"omitempty,oneof=TimeDow TimeMonth DurationSeconds DurationHours DurationDays"` Values []string `json:"values" yaml:"values"` } diff --git a/utils/validate_test.go b/utils/validate_test.go index d8d8a62..82b0129 100644 --- a/utils/validate_test.go +++ b/utils/validate_test.go @@ -47,7 +47,7 @@ func TestValidation(t *testing.T) { // _ = PrettyPrint(errs) assert.Equal(t, 2, len(errs)) assert.Equal(t, errs["PayPalWebsitePaymentsProCredentials.SupportedCurrencies[0]"], "SupportedCurrencies[0] must be one of [AUD BRL CAD CZK DKK EUR HKD HUF INR ILS JPY MYR MXN TWD NZD NOK PHP PLN GBP RUB SGD SEK CHF THB USD]") - assert.Equal(t, errs["Definition.Selector.Expressions[0].Operator"], "Operator must be one of [Equal NotEqual In NotIn Exists DoesNotExists Gt Lt Like InLike]") + assert.Equal(t, errs["Definition.Selector.Expressions[0].Operator"], "Operator must be one of [Equal NotEqual In NotIn Exists DoesNotExists Gt Lt Like InLike NotLike NotInLike]") } func TestLowerCaseName(t *testing.T) {