EmailAddress constructor

EmailAddress(
  1. String? str
)

Returns a valid EmailAddress object.

Throws ValueException:

Implementation

factory EmailAddress(String? str) {
  if (str == null || str.isEmpty) {
    throw const RequiredValueException();
  }

  if (validate(str)) {
    return EmailAddress._(str);
  }

  throw InvalidValueException(str, message: 'Invalid email address.');
}