@@ -11343,6 +11343,45 @@ func TestBicIsoFormatValidation(t *testing.T) {
1134311343 }
1134411344}
1134511345
11346+ func TestRFC1035LabelFormatValidation (t * testing.T ) {
11347+ tests := []struct {
11348+ value string `validate:"dns_rfc1035_label"`
11349+ tag string
11350+ expected bool
11351+ }{
11352+ {"abc" , "dns_rfc1035_label" , true },
11353+ {"abc-" , "dns_rfc1035_label" , false },
11354+ {"abc-123" , "dns_rfc1035_label" , true },
11355+ {"ABC" , "dns_rfc1035_label" , false },
11356+ {"ABC-123" , "dns_rfc1035_label" , false },
11357+ {"abc-abc" , "dns_rfc1035_label" , true },
11358+ {"ABC-ABC" , "dns_rfc1035_label" , false },
11359+ {"123-abc" , "dns_rfc1035_label" , false },
11360+ {"" , "dns_rfc1035_label" , false },
11361+ }
11362+
11363+ validate := New ()
11364+
11365+ for i , test := range tests {
11366+ errs := validate .Var (test .value , test .tag )
11367+
11368+ if test .expected {
11369+ if ! IsEqual (errs , nil ) {
11370+ t .Fatalf ("Index: %d dns_rfc1035_label failed Error: %s" , i , errs )
11371+ }
11372+ } else {
11373+ if IsEqual (errs , nil ) {
11374+ t .Fatalf ("Index: %d dns_rfc1035_label failed Error: %s" , i , errs )
11375+ } else {
11376+ val := getError (errs , "" , "" )
11377+ if val .Tag () != "dns_rfc1035_label" {
11378+ t .Fatalf ("Index: %d dns_rfc1035_label failed Error: %s" , i , errs )
11379+ }
11380+ }
11381+ }
11382+ }
11383+ }
11384+
1134611385func TestPostCodeByIso3166Alpha2 (t * testing.T ) {
1134711386 tests := map [string ][]struct {
1134811387 value string
0 commit comments