Skip to content

Commit 9d2b8ee

Browse files
joeybloggsjoeybloggs
authored andcommitted
updated coverage tests to be 100%
1 parent e1fd322 commit 9d2b8ee

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

validator_test.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,18 @@ func AssertMapFieldError(t *testing.T, s map[string]*FieldError, field string, e
231231
EqualSkip(t, 2, val.Tag, expectedTag)
232232
}
233233

234+
func TestBadKeyValidation(t *testing.T) {
235+
type Test struct {
236+
Name string `validate:"required, "`
237+
}
238+
239+
tst := &Test{
240+
Name: "test",
241+
}
242+
243+
PanicMatches(t, func() { validate.Struct(tst) }, "Invalid validation tag on field Name")
244+
}
245+
234246
func TestFlattenValidation(t *testing.T) {
235247

236248
type Inner struct {
@@ -623,9 +635,12 @@ func TestInterfaceErrValidation(t *testing.T) {
623635

624636
func TestMapDiveValidation(t *testing.T) {
625637

638+
n := map[int]interface{}{0: nil}
639+
err := validate.Field(n, "omitempty,required")
640+
626641
m := map[int]string{0: "ok", 3: "", 4: "ok"}
627642

628-
err := validate.Field(m, "len=3,dive,required")
643+
err = validate.Field(m, "len=3,dive,required")
629644
NotEqual(t, err, nil)
630645
Equal(t, err.IsPlaceholderErr, true)
631646
Equal(t, err.IsMap, true)

0 commit comments

Comments
 (0)