macAddressValidator static method

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

macAddressValidator to validate MAC address

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

Implementation

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