validator
validator copied to clipboard
Hostname ends with capital character is not accepted
Package version eg. v8, v9:
v9
Issue, Question or Enhancement:
The validator says the hostname which ends with a capital character is invalid.
The regular expression [-Az]
in regexes.go
may be incorrect.
regexes.go
const (
// ...
hostnameRegexStringRFC952 = `^[a-zA-Z][a-zA-Z0-9\-\.]+[a-z-Az0-9]$` // https://tools.ietf.org/html/rfc952
hostnameRegexStringRFC1123 = `^[a-zA-Z0-9][a-zA-Z0-9\-\.]+[a-z-Az0-9]$` // accepts hostname starting with a digit https://tools.ietf.org/html/rfc1123
// ...
)
Code sample, to showcase or reproduce:
validate.Var("aaA", "hostname")
Thanks, I'll take a look when I'm able.
This seems to be fixed with 9dedb06 so it's safe to close this. I can also open a PR for adding a test case for such a case, but it's already covered by "EXAMPLE" test case
@ki-ichino-nec Thank you for sharing the original issue. It should now be addressed in the most recent version. Please do not hesitate to follow up if you have any additional questions.