Skip to content

Commit

Permalink
corresponds to boolean value of nefield
Browse files Browse the repository at this point in the history
  • Loading branch information
Doarakko committed Dec 30, 2020
1 parent f6584a4 commit 607ccdd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions baked_in.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 5 additions & 0 deletions validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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
Expand All @@ -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)

Expand Down

0 comments on commit 607ccdd

Please sign in to comment.