apeye.email_validator
¶
Email address validation functions.
New in version 1.0.0.
This module is a subset of https://pypi.org/project/email-validator
Exceptions:
Exception raised when an email address fails validation because of its form. |
Classes:
|
Represents the return type of the |
Functions:
|
Validates an email address. |
|
Validate the domain part of an email address (the part after the @-sign). |
|
Validates the local part of an email address (the part before the @-sign). |
-
exception
EmailSyntaxError
[source]¶ Bases:
ValueError
Exception raised when an email address fails validation because of its form.
-
class
ValidatedEmail
(original_email, email, local_part, domain, *, ascii_email=None, ascii_local_part=None, ascii_domain=None, smtputf8=None)[source]¶ Bases:
object
Represents the return type of the
validate_email()
function.This class holds the normalized form of the email address alongside other information.
- Parameters
original_email (
str
) – The original, unnormalized email address.email (
str
) – The normalized email address, which should always be used in preference to the original address.local_part (
str
) – The local part of the email address after Unicode normalization.domain (
str
) – The domain part of the email address after Unicode normalization or conversion to Unicode from IDNA ascii.ascii_email (
Optional
[str
]) – If notNone
, a form of the email address that uses 7-bit ASCII characters only. DefaultNone
.ascii_local_part (
Optional
[str
]) – If notNone
, the local part of the email address using 7-bit ASCII characters only. DefaultNone
.ascii_domain (
Optional
[str
]) – If notNone
, a form of the domain name that uses 7-bit ASCII characters only. DefaultNone
.smtputf8 (
Optional
[bool
]) – Indicates whether SMTPUTF8 will be required to transmit messages to this address. DefaultNone
.
Methods:
__eq__
(other)Return
self == other
.__repr__
()Return a string representation of the
ValidatedEmail
.__str__
()Return
str(self)
.as_dict
()Convenience method for accessing the
ValidatedEmail
as a dict.Attributes:
If not
None
, a form of the domain name that uses 7-bit ASCII characters only.If not
None
, a form of the email address that uses 7-bit ASCII characters only.If not
None
, the local part of the email address using 7-bit ASCII characters only.The domain part of the email address after Unicode normalization or conversion to Unicode from IDNA ascii.
The normalized email address, which should always be used in preference to the original address.
The local part of the email address after Unicode normalization.
The email address that was passed to validate_email.
If
True
, the SMTPUTF8 feature of your mail relay will be required to transmit messages to this address.-
__repr__
()[source]¶ Return a string representation of the
ValidatedEmail
.- Return type
-
as_dict
()[source]¶ Convenience method for accessing the
ValidatedEmail
as a dict.
-
ascii_local_part
¶ -
If not
None
, the local part of the email address using 7-bit ASCII characters only.
-
domain
¶ Type:
str
The domain part of the email address after Unicode normalization or conversion to Unicode from IDNA ascii.
-
email
¶ Type:
str
The normalized email address, which should always be used in preference to the original address.
The normalized address converts an IDNA ASCII domain name to Unicode, if possible, and performs Unicode normalization on the local part and on the domain (if originally Unicode). It is the concatenation of the local_part and domain attributes, separated by an @-sign.
-
validate_email
(email, allow_smtputf8=True, allow_empty_local=False)[source]¶ Validates an email address.
- Parameters
- Raises
EmailSyntaxError – if the address is not valid
- Return type
-
validate_email_domain_part
(domain)[source]¶ Validate the domain part of an email address (the part after the @-sign).