From 89f2faae2670246f29172fd6810acf470b3f1494 Mon Sep 17 00:00:00 2001 From: Tom Kay Date: Wed, 24 Jul 2024 11:39:50 +0100 Subject: [PATCH 1/2] add Like and InLike to validation --- selector/predicates.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/selector/predicates.go b/selector/predicates.go index a5cb39b..75ac7fc 100644 --- a/selector/predicates.go +++ b/selector/predicates.go @@ -28,7 +28,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"` + Operator PredicateOperator `json:"operator" yaml:"operator" validate:"oneof=Equal NotEqual In NotIn Exists DoesNotExists Gt Lt Like InLike"` Conversion OperatorConversion `json:"conversion" yaml:"conversion" validate:"omitempty,oneof=TimeDow TimeMonth DurationSeconds DurationHours DurationDays"` Values []string `json:"values" yaml:"values"` } From 057ae0b74e0c1a88b72da0c098afcb43a85b9cad Mon Sep 17 00:00:00 2001 From: Tom Kay Date: Wed, 24 Jul 2024 11:40:57 +0100 Subject: [PATCH 2/2] fix test --- utils/validate_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/validate_test.go b/utils/validate_test.go index 163b1cd..d8d8a62 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]") + assert.Equal(t, errs["Definition.Selector.Expressions[0].Operator"], "Operator must be one of [Equal NotEqual In NotIn Exists DoesNotExists Gt Lt Like InLike]") } func TestLowerCaseName(t *testing.T) {