From d1178535f7442b82ac8b63929af35c279066473f Mon Sep 17 00:00:00 2001 From: Dean Karn Date: Sun, 19 Mar 2023 11:44:44 -0700 Subject: [PATCH] change eq and ne ignore case tag names --- baked_in.go | 6 +++--- validator_test.go | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/baked_in.go b/baked_in.go index b9c3fdd..e08442b 100644 --- a/baked_in.go +++ b/baked_in.go @@ -86,9 +86,9 @@ var ( "min": hasMinOf, "max": hasMaxOf, "eq": isEq, - "eqIgnoreCase": isEqIgnoreCase, + "eq_ignore_case": isEqIgnoreCase, "ne": isNe, - "neIgnoreCase": isNeIgnoreCase, + "ne_ignore_case": isNeIgnoreCase, "lt": isLt, "lte": isLte, "gt": isGt, @@ -1272,7 +1272,7 @@ func isEq(fl FieldLevel) bool { } // isEqIgnoreCase is the validation function for validating if the current field's string value is -//equal to the param's value. +// equal to the param's value. // The comparison is case-insensitive. func isEqIgnoreCase(fl FieldLevel) bool { field := fl.Field() diff --git a/validator_test.go b/validator_test.go index 8c9a4dd..9ffcd9c 100644 --- a/validator_test.go +++ b/validator_test.go @@ -5213,15 +5213,15 @@ func TestIsNeIgnoreCaseValidation(t *testing.T) { s := "abcd" now := time.Now() - errs = validate.Var(s, "neIgnoreCase=efgh") + errs = validate.Var(s, "ne_ignore_case=efgh") Equal(t, errs, nil) - errs = validate.Var(s, "neIgnoreCase=AbCd") + errs = validate.Var(s, "ne_ignore_case=AbCd") NotEqual(t, errs, nil) - AssertError(t, errs, "", "", "", "", "neIgnoreCase") + AssertError(t, errs, "", "", "", "", "ne_ignore_case") PanicMatches( - t, func() { _ = validate.Var(now, "eqIgnoreCase=abcd") }, "Bad field type time.Time", + t, func() { _ = validate.Var(now, "ne_ignore_case=abcd") }, "Bad field type time.Time", ) } @@ -5508,14 +5508,14 @@ func TestIsEqIgnoreCaseValidation(t *testing.T) { s := "abcd" now := time.Now() - errs = validate.Var(s, "eqIgnoreCase=abcd") + errs = validate.Var(s, "eq_ignore_case=abcd") Equal(t, errs, nil) - errs = validate.Var(s, "eqIgnoreCase=AbCd") + errs = validate.Var(s, "eq_ignore_case=AbCd") Equal(t, errs, nil) PanicMatches( - t, func() { _ = validate.Var(now, "eqIgnoreCase=abcd") }, "Bad field type time.Time", + t, func() { _ = validate.Var(now, "eq_ignore_case=abcd") }, "Bad field type time.Time", ) }