validatePhone static method
Implementation
static String? validatePhone(String? value) {
if (value == null || value.isEmpty) {
return 'Please enter a valid phone number. Ex. (573) 434-1234';
}
var phoneRegex = RegExp(r'\(\d{3}\)\s\d{3}-\d{4}');
if (!phoneRegex.hasMatch(value)) {
return 'Please enter phone number in the form "(573) 434-1234"';
}
return null;
}