JSONSchex.Formats.IP (jsonschex v0.5.0)

Copy Markdown View Source

Validates ipv4 and ipv6 formats.

Summary

Functions

Validates an IPv4 address in dotted-decimal notation.

Validates an IPv6 address using Erlang's :inet.parse_ipv6_address/1.

Functions

valid_ipv4?(data)

@spec valid_ipv4?(binary()) :: boolean()

Validates an IPv4 address in dotted-decimal notation.

Rejects leading zeros (e.g., "01.02.03.04"), values > 255, and non-numeric characters. Uses pure binary pattern matching for maximum performance — no regex, no String.split, no String.to_integer.

valid_ipv6?(data)

@spec valid_ipv6?(binary()) :: boolean()

Validates an IPv6 address using Erlang's :inet.parse_ipv6_address/1.

Rejects addresses containing a zone ID (%), which is not allowed by the JSON Schema specification.