ipv6Validator static method

String? ipv6Validator(
  1. String? value, [
  2. String? errorMessage
])

ipv6Validator to validate ipv6

validator: (value) => SimpleValidations.ipv6Validator(value, [errorMessage]),

Implementation

static String? ipv6Validator(String? value, [String? errorMessage]) {
  RegExp regex = CustomRegEx.ipv6Regex;
  if (value == null || value.isEmpty) {
    return errorMessage ?? 'Required';
  } else if (!regex.hasMatch(value)) {
    return errorMessage ?? 'Please enter a valid IPv6 address';
  }
  return null;
}