validators.email
eMail.
@validator
def
email( value: str, /, *, ipv6_address: bool = False, ipv4_address: bool = False, simple_host: bool = False, rfc_1034: bool = False, rfc_2782: bool = False):
Validate an email address.
This was inspired from Django's email validator. Also ref: RFC 1034, RFC 5321 and RFC 5322.
Examples:
>>> email('someone@example.com') True >>> email('bogus@@') ValidationError(func=email, args={'value': 'bogus@@'})
Arguments:
- value: eMail string to validate.
- ipv6_address: When the domain part is an IPv6 address.
- ipv4_address: When the domain part is an IPv4 address.
- simple_host: When the domain part is a simple hostname.
- rfc_1034: Allow trailing dot in domain name. Ref: RFC 1034.
- rfc_2782: Domain name is of type service record. Ref: RFC 2782.
Returns:
(Literal[True]): If
valueis a valid eMail. (ValidationError): Ifvalueis an invalid eMail.