email¶
- validators.email.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][1]. Also ref: [RFC 1034][2], [RFC 5321][3] and [RFC 5322][4].
[1]: https://github.com/django/django/blob/main/django/core/validators.py#L174 [2]: https://www.rfc-editor.org/rfc/rfc1034 [3]: https://www.rfc-editor.org/rfc/rfc5321 [4]: https://www.rfc-editor.org/rfc/rfc5322
Examples
>>> email('someone@example.com') True >>> email('bogus@@') ValidationError(func=email, args={'value': 'bogus@@'})
- Parameters:
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](https://www.rfc-editor.org/rfc/rfc1034).
rfc_2782 – Domain name is of type service record. Ref: [RFC 2782](https://www.rfc-editor.org/rfc/rfc2782).
- Returns:
If value is a valid eMail. (ValidationError): If value is an invalid eMail.
- Return type:
(Literal[True])