Skip to content

.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.

StringValidator<O> email({String? message, MessageBuilder? messageBuilder})
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.

@IsEmail(), or the constant @isEmail. Put the annotation on the constructor parameter or the field.

final email = l.string().email();
email.validate(input)+2-1
  1. valid: '[email protected]'
  2. valid: 'user@localhost'
  3. invalid: 'bad'value must be a valid email address