test case for “eq” comparing boolean values #547

pull/547/head
Dmitry M. Gavrovsky 5 years ago
parent dfc652373a
commit d149847e8a
  1. 19
      validator_test.go

@ -7191,6 +7191,25 @@ func TestRequired(t *testing.T) {
AssertError(t, err.(ValidationErrors), "Test.Value", "Test.Value", "Value", "Value", "required") AssertError(t, err.(ValidationErrors), "Test.Value", "Test.Value", "Value", "Value", "required")
} }
func TestBoolEqual(t *testing.T) {
validate := New()
type Test struct {
Value bool `validate:"eq=true"`
}
var test Test
err := validate.Struct(test)
NotEqual(t, err, nil)
AssertError(t, err.(ValidationErrors), "Test.Value", "Test.Value", "Value", "Value", "eq")
test.Value = true
err = validate.Struct(test)
Equal(t, err, nil)
}
func TestTranslations(t *testing.T) { func TestTranslations(t *testing.T) {
en := en.New() en := en.New()
uni := ut.New(en, en, fr.New()) uni := ut.New(en, en, fr.New())

Loading…
Cancel
Save