Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests to demonstrate how the validation.Required rule works with boolean values and pointers #18

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add unit tests to demonstrate how booleans work with the Required rule
sl255051 committed Sep 19, 2023
commit dc70d331a69eaf2910d94e2a45b8299fea45959f
8 changes: 8 additions & 0 deletions required_test.go
Original file line number Diff line number Diff line change
@@ -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 {