• Ip()
  • Ip(string $range)
  • Ip(string $range, int $options)

Validates whether the input is a valid IP address.

This validator uses the native filter_var() PHP function.

v::ip()->validate(''); // true
v::ip('')->validate(''); // true
v::ip('')->validate(''); // false

You can pass a parameter with filter_var() flags for IP.

v::ip('*', FILTER_FLAG_NO_PRIV_RANGE)->validate(''); // false

If you want to validate IPv6 you can do as follow:

v::ip('*', FILTER_FLAG_IPV6)->validate('2001:0db8:85a3:08d3:1319:8a2e:0370:7334'); // true


  • Internet


Version Description
2.0.0 Allow to define range and options to the same instance
0.5.0 Implemented IP range validation
0.3.9 Created

See also: