isEmailField static method
Validator to check if a field contains a valid email address.
The validator checks whether the provided value is non-null, is a non-empty
string, and matches the format of an email address. If the validation fails,
an error message 'error.field.email'
is returned.
Returns:
FieldValidateResult
: A result indicating whether the validation passed or failed, including any associated error messages.
Implementation
static ValidatorEvent isEmailField() => (value) {
var res = (value != null && value.toString().trim().isEmail);
return FieldValidateResult(
success: res,
error: res ? '' : 'error.field.email',
);
};