Skip to content

Commit 5a8c7c5

Browse files
authored
Add unit tests to demonstrate how booleans work with the Required rule (#18)
1 parent 5ef98ee commit 5a8c7c5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

required_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ func TestRequired(t *testing.T) {
1616
s2 := ""
1717
var time1 time.Time
1818
var myStruct MyStruct
19+
b1 := true
20+
b2 := false
21+
var b3 *bool
1922
tests := []struct {
2023
tag string
2124
value interface{}
@@ -29,6 +32,11 @@ func TestRequired(t *testing.T) {
2932
{"t6", time1, "cannot be blank"},
3033
{"t7", myStruct, "cannot be blank"},
3134
{"t8", &myStruct, "cannot be blank"},
35+
{"t9", b1, ""},
36+
{"t10", b2, "cannot be blank"},
37+
{"t11", b3, "cannot be blank"},
38+
{"t12", &b1, ""},
39+
{"t13", &b2, "cannot be blank"},
3240
}
3341

3442
for _, test := range tests {

0 commit comments

Comments
 (0)