apeye.email_validator
¶
Source code: apeye_core/email_validator.py
Email address validation functions.
New in version 1.0.0.
This module is a subset of https://pypi.org/project/email-validator
Note
The classes in this module can instead be imported from the apeye_core.email_validator module instead.
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)¶
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
object.__str__
()Return a string representation of the
ValidatedEmail
object.as_dict
()Convenience method for accessing the
ValidatedEmail
as a dict.- __repr__()[source]¶
Return a string representation of the
ValidatedEmail
object.- Return type
- __str__()[source]¶
Return a string representation of the
ValidatedEmail
object.- Return type
- 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).