validateEmail static method
Implementation
static String? validateEmail(String? value) {
if (value == null || value.isEmpty) {
return 'Email is required';
} else if (!value.contains('@') || !value.contains('.')) {
return 'Please enter a valid email';
} else if (!RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$').hasMatch(value)) {
return 'Please enter a valid email format';
}
return null;
}