Update timeZone tag name to timezone

pull/641/head
math-nao 4 years ago
parent 44f3347f13
commit 7dbe685a02
  1. 2
      baked_in.go
  2. 2
      doc.go
  3. 16
      validator_test.go

@ -174,7 +174,7 @@ var (
"lowercase": isLowercase, "lowercase": isLowercase,
"uppercase": isUppercase, "uppercase": isUppercase,
"datetime": isDatetime, "datetime": isDatetime,
"timeZone": isTimeZone, "timezone": isTimeZone,
} }
) )

@ -1094,7 +1094,7 @@ This validates that a string value is a valid time zone based on the time zone d
Although empty value and Local value are allowed by time.LoadLocation golang function, they are not allowed by this validator. Although empty value and Local value are allowed by time.LoadLocation golang function, they are not allowed by this validator.
More information on https://golang.org/pkg/time/#LoadLocation More information on https://golang.org/pkg/time/#LoadLocation
Usage: timeZone Usage: timezone
Alias Validators and Tags Alias Validators and Tags

@ -9204,16 +9204,16 @@ func TestDatetimeValidation(t *testing.T) {
func TestTimeZoneValidation(t *testing.T) { func TestTimeZoneValidation(t *testing.T) {
tests := []struct { tests := []struct {
value string `validate:"timeZone"` value string `validate:"timezone"`
tag string tag string
expected bool expected bool
}{ }{
// systems may have different time zone database, some systems time zone are case insensitive // systems may have different time zone database, some systems time zone are case insensitive
{"America/New_York", `timeZone`, true}, {"America/New_York", `timezone`, true},
{"UTC", `timeZone`, true}, {"UTC", `timezone`, true},
{"", `timeZone`, false}, {"", `timezone`, false},
{"Local", `timeZone`, false}, {"Local", `timezone`, false},
{"Unknown", `timeZone`, false}, {"Unknown", `timezone`, false},
} }
validate := New() validate := New()
@ -9231,7 +9231,7 @@ func TestTimeZoneValidation(t *testing.T) {
t.Fatalf("Index: %d time zone failed Error: %s", i, errs) t.Fatalf("Index: %d time zone failed Error: %s", i, errs)
} else { } else {
val := getError(errs, "", "") val := getError(errs, "", "")
if val.Tag() != "timeZone" { if val.Tag() != "timezone" {
t.Fatalf("Index: %d time zone failed Error: %s", i, errs) t.Fatalf("Index: %d time zone failed Error: %s", i, errs)
} }
} }
@ -9239,6 +9239,6 @@ func TestTimeZoneValidation(t *testing.T) {
} }
PanicMatches(t, func() { PanicMatches(t, func() {
_ = validate.Var(2, "timeZone") _ = validate.Var(2, "timezone")
}, "Bad field type int") }, "Bad field type int")
} }

Loading…
Cancel
Save