.email()
Passes when the string follows the RFC 5322 address syntax. It accepts single-label domains such as user@localhost, does not limit the local part to 64 characters, and rejects internationalized (Unicode) addresses. It checks shape, not deliverability.
Signature
Section titled “Signature”StringValidator<O> email({String? message, MessageBuilder? messageBuilder})Parameters
Section titled “Parameters”| Parameter | Type | Meaning |
|---|---|---|
message |
String? |
Replaces the default error message. |
messageBuilder |
MessageBuilder? |
Builds the message from the issue. message wins when both are given. See Message builders. |
Code invalidEmail. Default message: value must be a valid email address. value is replaced by the field name when there is one.
Code generation
Section titled “Code generation”@IsEmail(), or the constant @isEmail. Put the annotation on the constructor parameter or the field.
Example
Section titled “Example”final email = l.string().email();@IsEmail() required String email, // l.string().email().required()email.validate(input)+2-1- valid:
'[email protected]' - valid:
'user@localhost' - invalid:
'bad'