v9
If a fqdn starts with an integer f.e. "0.de.pool.ntp.org", the validation fails. The example "0.de.pool.ntp.org" is a valid ntp-server (see https://www.pool.ntp.org/zone/de).
package main
import(
"fmt"
"gopkg.in/go-playground/validator.v9"
)
type SettingsNtp struct {
NtpServer string `json:"ntpServer" validate:"required,ipv4|fqdn"`
}
func main() {
validNtp1 := SettingsNtp{ NtpServer: "de.pool.ntp.org"} // valid ntp-server see https://www.pool.ntp.org/zone/de
validNtp2 := SettingsNtp{ NtpServer: "0.de.pool.ntp.org"} // valid ntp-server see https://www.pool.ntp.org/zone/de
fmt.Println("validator fqdn")
validate := validator.New()
errs := validate.Struct(validNtp1) //this validation is succeeded
if errs != nil {
fmt.Println(errs)
} else {
fmt.Println("No errors validNtp1")
}
errs = validate.Struct(validNtp2) //this validation fails
if errs != nil {
fmt.Println(errs)
} else {
fmt.Println("No errors validNtp2")
}
}
@deschmih thanks for reporting.
Hoping someone can help with this as my time is very limited ATM.
This issue was resolved, it should be closed
Many thx