Fixed "Assignment Branch Condition too high"

pull/298/head
Bruno Lorenz 7 years ago
parent 08796346a0
commit 1669b6e0ee
  1. 4
      baked_in.go
  2. 1
      validator_test.go

@ -1487,8 +1487,8 @@ func isHostname(fl FieldLevel) bool {
func isFQDN(fl FieldLevel) bool { func isFQDN(fl FieldLevel) bool {
val := fl.Field().String() val := fl.Field().String()
if val[len(val)-1] == '.' && val[len(val)-2] != '.' { if val[len(val)-1] == '.' {
val = strings.TrimRight(val, ".") val = val[0 : len(val)-1]
} }
return hostnameRegex.MatchString(val) && return hostnameRegex.MatchString(val) &&

@ -7182,6 +7182,7 @@ func TestFQDNValidation(t *testing.T) {
{"example24.com.", true}, {"example24.com.", true},
{"test.example24.com.", true}, {"test.example24.com.", true},
{"test24.example24.com.", true}, {"test24.example24.com.", true},
{"test24.example24.com..", false},
{"example", false}, {"example", false},
{"192.168.0.1", false}, {"192.168.0.1", false},
{"email@example.com", false}, {"email@example.com", false},

Loading…
Cancel
Save