ip static method

FormFieldValidator<String> ip({
  1. int version = 4,
  2. RegExp? regex,
  3. String? errorText,
  4. bool checkNullOrEmpty = true,
})

FormFieldValidator that requires the field's value to be a valid IP address.

Parameters:

  • version The IP version (4 or 6).
  • regex The regex pattern to match.
  • errorText The error message when the IP address is invalid.
  • checkNullOrEmpty Whether to check for null or empty values.

This regex matches an IPv4 address.

  • It consists of four groups of one to three digits.
  • Each group is separated by a dot.
  • Each group can range from 0 to 255.

Examples: 192.168.1.1, 10.0.0.1

This regex matches an IPv6 address.

  • It supports various valid IPv6 notations.
  • It allows the use of "::" for consecutive zero blocks.
  • It allows hexadecimal digits and colons.

Examples: ::1, 2001:0db8:85a3:0000:0000:8a2e:0370:7334

Implementation

static FormFieldValidator<String> ip({
  int version = 4,
  RegExp? regex,
  String? errorText,
  bool checkNullOrEmpty = true,
}) => IpValidator(
  version: version,
  regex: regex,
  errorText: errorText,
  checkNullOrEmpty: checkNullOrEmpty,
).validate;