Skip to content

Commit d149847

Browse files
committed
test case for “eq” comparing boolean values #547
1 parent dfc6523 commit d149847

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

validator_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7191,6 +7191,25 @@ func TestRequired(t *testing.T) {
71917191
AssertError(t, err.(ValidationErrors), "Test.Value", "Test.Value", "Value", "Value", "required")
71927192
}
71937193

7194+
func TestBoolEqual(t *testing.T) {
7195+
7196+
validate := New()
7197+
7198+
type Test struct {
7199+
Value bool `validate:"eq=true"`
7200+
}
7201+
7202+
var test Test
7203+
7204+
err := validate.Struct(test)
7205+
NotEqual(t, err, nil)
7206+
AssertError(t, err.(ValidationErrors), "Test.Value", "Test.Value", "Value", "Value", "eq")
7207+
7208+
test.Value = true
7209+
err = validate.Struct(test)
7210+
Equal(t, err, nil)
7211+
}
7212+
71947213
func TestTranslations(t *testing.T) {
71957214
en := en.New()
71967215
uni := ut.New(en, en, fr.New())

0 commit comments

Comments
 (0)