phone static method
Implementation
static String? Function(dynamic) phone({
String message = "Invalid phone number",
}) {
// Basic international format or 10-digit
final phoneRegex = RegExp(r'^\+?[0-9]{10,15}$');
return (value) {
if (value == null || value.toString().isEmpty) return null;
if (!phoneRegex.hasMatch(
value.toString().replaceAll(RegExp(r'[\s\-\(\)]'), ''),
)) {
return message;
}
return null;
};
}