From 607ccdd8ae697db5806d50442f718d4ca5b039f7 Mon Sep 17 00:00:00 2001 From: peperoncino <2wua4nlyi@gmail.com> Date: Thu, 31 Dec 2020 07:42:28 +0900 Subject: [PATCH] corresponds to boolean value of nefield --- baked_in.go | 3 +++ validator_test.go | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/baked_in.go b/baked_in.go index 6ce762d1..bcb0fbb8 100644 --- a/baked_in.go +++ b/baked_in.go @@ -791,6 +791,9 @@ func isNeField(fl FieldLevel) bool { case reflect.Slice, reflect.Map, reflect.Array: return int64(field.Len()) != int64(currentField.Len()) + case reflect.Bool: + return field.Bool() != currentField.Bool() + case reflect.Struct: fieldType := field.Type() diff --git a/validator_test.go b/validator_test.go index 683a2ddd..92a62745 100644 --- a/validator_test.go +++ b/validator_test.go @@ -4557,6 +4557,7 @@ func TestIsNeFieldValidation(t *testing.T) { i := 1 j = 1 k = 1.543 + b := true arr := []string{"test"} now := time.Now().UTC() @@ -4566,6 +4567,7 @@ func TestIsNeFieldValidation(t *testing.T) { i2 := 3 j2 = 2 k2 = 1.5434456 + b2 := false arr2 := []string{"test", "test2"} arr3 := []string{"test"} now2 := now @@ -4582,6 +4584,9 @@ func TestIsNeFieldValidation(t *testing.T) { errs = validate.VarWithValue(k2, k, "nefield") Equal(t, errs, nil) + errs = validate.VarWithValue(b2, b, "nefield") + Equal(t, errs, nil) + errs = validate.VarWithValue(arr2, arr, "nefield") Equal(t, errs, nil)