Skip to content

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

@hsharma001

Description

@hsharma001

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

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

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions