email static method
Validates email format.
Implementation
static String? email(String? value, {String? message}) {
if (value == null || value.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 ?? 'Please enter a valid email address.';
}
return null;
}