macAddressValidator static method
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;
}