func TestEmailInValid(t *testing.T) { v := struct { Email string `email:"-"` }{ "fuga", } if err := gova.Validate(v); err == nil { t.Error("email validator doesn't work!") } }
func TestEmailValid(t *testing.T) { v := struct { Email string `email:"-"` }{ "*****@*****.**", } if err := gova.Validate(v); err != nil { t.Error(err) } }
func TestPatternValid(t *testing.T) { v := struct { Num string `pattern:"[0-9]+"` }{ "11111", } if err := gova.Validate(v); err != nil { t.Error(err) } }
func TestPatternInValid(t *testing.T) { v := struct { Num string `pattern:"[0-9]+"` }{ "fuga", } if err := gova.Validate(v); err == nil { t.Error("pattern validator doesn't work!") } }
func TestLengthValid(t *testing.T) { v := struct { Str string `length:"10"` }{ "1234567890", } if err := gova.Validate(v); err != nil { t.Error(err) } }
func TestLengthInValid(t *testing.T) { v := struct { Str string `length:"10"` }{ "1234", } if err := gova.Validate(v); err == nil { t.Error("length validator doesn't work!") } }
func TestStructPointerResolutionValidation(t *testing.T) { // this test should not cause panic tmp := &Form{"alpha"} gova.Validate(tmp) }