email static method
Validates email format
Implementation
static String? Function(String?) email({String? message}) {
return (String? value) {
if (value == null || value.trim().isEmpty) {
return null;
}
final emailRegex = RegExp(
r'^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$',
);
if (!emailRegex.hasMatch(value)) {
return message ?? _defaultMessages['email'];
}
return null;
};
}