#1561·validator

[Bug]: hostname_rfc1123 validation does not enforce IPv4 octet check

Author: hsharma001Created Apr 15, 2026Updated Apr 27, 2026
Labelsbug

What happened?

According to rfc1123: "a valid host name can never have the dotted-decimal form #.#.#.#, since at least the highest-level component label will be alphabetic." However, for example, 277.168.0.1 is returned as a valid host, which is not a valid IPv4 address because of the first octet and should not be a valid hostname based on the rfc quoted above.

Version

v10

Example Code

go
func TestHostnameRFC1123Validation(t *testing.T) {
	tests := []struct {
		param    string
		expected bool
	}{
		{"277.168.0.1", false},
         }
....
}

--- FAIL: TestHostnameRFC1123Validation (0.00s)
validator-master/validator_test.go:10679: Hostname: {277.168.0.1 false} failed Error: <nil>
FAIL
FAIL	github.com/go-playground/validator/v10	0.011s
FAIL