From dc70d331a69eaf2910d94e2a45b8299fea45959f Mon Sep 17 00:00:00 2001 From: Steve Lessard Date: Tue, 19 Sep 2023 11:09:31 -0700 Subject: [PATCH] Add unit tests to demonstrate how booleans work with the Required rule --- required_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/required_test.go b/required_test.go index 1077014..d71e6b1 100644 --- a/required_test.go +++ b/required_test.go @@ -16,6 +16,9 @@ func TestRequired(t *testing.T) { s2 := "" var time1 time.Time var myStruct MyStruct + b1 := true + b2 := false + var b3 *bool tests := []struct { tag string value interface{} @@ -29,6 +32,11 @@ func TestRequired(t *testing.T) { {"t6", time1, "cannot be blank"}, {"t7", myStruct, "cannot be blank"}, {"t8", &myStruct, "cannot be blank"}, + {"t9", b1, ""}, + {"t10", b2, "cannot be blank"}, + {"t11", b3, "cannot be blank"}, + {"t12", &b1, ""}, + {"t13", &b2, "cannot be blank"}, } for _, test := range tests {