[x] I have looked at the documentation here first?
[x] I have looked at the examples provided that may showcase my question here?
v10:
Hi everyone
I just noticed the FQDN validator doesn't work properly
It accepts the "-" symbol at the ends of n domain level
I searched is this planned or any other github issue was already created, but I didn't find anything similar
Issue, Question or Enhancement:
Here you can see screenshots the regex is satisfies with a "domain-.com" example
Code sample, to showcase or reproduce:
package main
import (
"fmt"
"github.com/go-playground/validator/v10"
)
func main() {
validate := validator.New()
err := validate.Var("google.com", "required,fqdn")
if err != nil {
fmt.Println(err.Error())
return
}
err = validate.Var("google-.com", "required,fqdn")
if err != nil {
fmt.Println(err.Error())
return
}
fmt.Println("Everything is ok, but it shouldn't cause the \"google-.com\" is not looking as a valid domain name")
err = validate.Var("-google.com", "required,fqdn")
if err != nil {
fmt.Printf("For example, this is invalid as expected: %s", err.Error())
return
}
}
v10:
Hi everyone
I just noticed the FQDN validator doesn't work properly It accepts the "-" symbol at the ends of n domain level
I searched is this planned or any other github issue was already created, but I didn't find anything similar
Issue, Question or Enhancement:
Here you can see screenshots the regex is satisfies with a "domain-.com" example
Code sample, to showcase or reproduce:
Possible solution:
I found a regex which can possibly resolve this issue (but I didn't test anything except the regex itself via regex101) https://stackoverflow.com/questions/10306690/what-is-a-regular-expression-which-will-match-a-valid-domain-name-without-a-subd