diff --git a/baked_in.go b/baked_in.go index e170da9..a74c5a7 100644 --- a/baked_in.go +++ b/baked_in.go @@ -1494,6 +1494,10 @@ func isHostname(fl FieldLevel) bool { func isFQDN(fl FieldLevel) bool { val := fl.Field().String() + if val == "" { + return false + } + if val[len(val)-1] == '.' { val = val[0 : len(val)-1] } diff --git a/validator_test.go b/validator_test.go index 4459529..6f57671 100644 --- a/validator_test.go +++ b/validator_test.go @@ -7189,6 +7189,7 @@ func TestFQDNValidation(t *testing.T) { {"2001:cdba:0000:0000:0000:0000:3257:9652", false}, {"2001:cdba:0:0:0:0:3257:9652", false}, {"2001:cdba::3257:9652", false}, + {"", false}, } validate := New()