Skip to content

ip ​

Checks that the value is an IPv4 or an IPv6 address.

Error codes: WRONG_IP, FORMAT_ERROR

Live example · edit rules or inputOpen in playground
rules
input
Invaliderrors
{
  "gateway": "WRONG_IP"
}

{ ip: 'v4' } accepts IPv4 only, { ip: 'v6' } IPv6 only, 'ip' both.

  • IPv4: four decimal numbers 0–255 separated by ., without leading zeros. 010.0.0.1 is rejected: some systems read it as octal.
  • IPv6: the text forms of RFC 4291, section 2.2: eight groups of 1–4 hex digits separated by :. One :: may replace one or more groups of zeros. The last two groups may be an IPv4 address in the form above (::ffff:192.0.2.1). No zone ID (%eth0), no brackets, no prefix length.

For an address with a prefix length, use cidr.