EmailAddress constructor
EmailAddress(
- String? str
Returns a valid EmailAddress object.
Throws ValueException:
- RequiredValueException if
str
is null or empty. - InvalidValueException if
str
is not a valid email address.
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.');
}