validatePhoneNumber static method
Implementation
static String? validatePhoneNumber(String? val) {
String value=(val??"").toString().replaceAll(" ", "").replaceAll("(", "").replaceAll(")", "").replaceAll("-", "");
if (value.isEmpty) return "Phone number is required";
final phoneRegex = RegExp(r'^\d{10}$');
return phoneRegex.hasMatch(value)
? null
: "Enter a valid 10-digit phone number";
}