2024-03-18 13:23:58 +08:00
|
|
|
class ValidatorUtil {
|
|
|
|
String? emailValidator(value) {
|
|
|
|
if (value == null || value == '') {
|
|
|
|
return 'Email is required';
|
|
|
|
}
|
2024-03-31 17:13:29 +08:00
|
|
|
const String regexEmail =
|
2024-03-18 13:23:58 +08:00
|
|
|
"^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*\$";
|
|
|
|
if (value == null || value.isEmpty) return null;
|
2024-03-31 17:13:29 +08:00
|
|
|
return RegExp(regexEmail).hasMatch(value) ? null : 'Email format error';
|
2024-03-18 13:23:58 +08:00
|
|
|
}
|
|
|
|
}
|