From d149847e8a29041fa9f3f258455e8a9b10119646 Mon Sep 17 00:00:00 2001 From: "Dmitry M. Gavrovsky" Date: Tue, 19 Nov 2019 21:07:19 +0200 Subject: [PATCH] =?UTF-8?q?test=20case=20for=20=E2=80=9Ceq=E2=80=9D=20comp?= =?UTF-8?q?aring=20boolean=20values=20#547?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- validator_test.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/validator_test.go b/validator_test.go index 2787f9e..03264a2 100644 --- a/validator_test.go +++ b/validator_test.go @@ -7191,6 +7191,25 @@ func TestRequired(t *testing.T) { 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) { en := en.New() uni := ut.New(en, en, fr.New())