You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,7 @@ There are no significant changes to which email addresses are considered valid/i
11
11
* Some syntax error messages have changed because they are now checked explicitly rather than as a part of other checks.
12
12
* The quoted-string local part syntax (e.g. multiple @-signs, spaces, etc. if surrounded by quotes) and domain-literal addresses (e.g. @[192.XXX...] or @[IPv6:...]) are now parsed but not considered valid by default. Better error messages are now given for these addresses since it can be confusing for a technically valid address to be rejected, and new allow_quoted_local and allow_domain_literal options are added to allow these addresses if you really need them.
13
13
* Some other error messages have changed to not repeat the email address in the error message.
14
+
* The `email` field on the returned `ValidatedEmail` object has been renamed to `normalized` to be clearer about its importance, but access via `.email` is also still supported.
14
15
* The library has been reorganized internally into smaller modules.
15
16
* The tests have been reorganized and expanded. Deliverability tests now mostly use captured DNS responses so they can be run off-line.
16
17
* The __main__ tool now reads options to validate_email from environment variables.
|`email`| The normalized form of the email address that you should put in your database. This combines the `local_part` and `domain` fields (see below). |
384
-
|`ascii_email`| If set, an ASCII-only form of the email address by replacing the domain part with [IDNA](https://tools.ietf.org/html/rfc5891)[Punycode](https://www.rfc-editor.org/rfc/rfc3492.txt). This field will be present when an ASCII-only form of the email address exists (including if the email address is already ASCII). If the local part of the email address contains internationalized characters, `ascii_email` will be `None`. If set, it merely combines `ascii_local_part` and `ascii_domain`. |
383
+
|`normalized`| The normalized form of the email address that you should put in your database. This combines the `local_part` and `domain` fields (see below). |
384
+
|`ascii_email`| If set, an ASCII-only form of the normalized email address by replacing the domain part with [IDNA](https://tools.ietf.org/html/rfc5891)[Punycode](https://www.rfc-editor.org/rfc/rfc3492.txt). This field will be present when an ASCII-only form of the email address exists (including if the email address is already ASCII). If the local part of the email address contains internationalized characters, `ascii_email` will be `None`. If set, it merely combines `ascii_local_part` and `ascii_domain`. |
385
385
|`local_part`| The normalized local part of the given email address (before the @-sign). Normalization includes Unicode NFC normalization and removing unnecessary quoted-string quotes and backslashes. If `allow_quoted_local` is True and the surrounding quotes are necessary, the quotes _will_ be present in this field. |
386
386
|`ascii_local_part`| If set, the local part, which is composed of ASCII characters only. |
387
387
|`domain`| The canonical internationalized Unicode form of the domain part of the email address. If the returned string contains non-ASCII characters, either the [SMTPUTF8](https://tools.ietf.org/html/rfc6531) feature of your mail relay will be required to transmit the message or else the email address's domain part must be converted to IDNA ASCII first: Use `ascii_domain` field instead. |
Copy file name to clipboardExpand all lines: email_validator/exceptions_types.py
+13-5Lines changed: 13 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -22,13 +22,13 @@ class ValidatedEmail(object):
22
22
and other information."""
23
23
24
24
"""The email address that was passed to validate_email. (If passed as bytes, this will be a string.)"""
25
-
original_email: str
25
+
original: str
26
26
27
27
"""The normalized email address, which should always be used in preferance to the original address.
28
28
The normalized address converts an IDNA ASCII domain name to Unicode, if possible, and performs
29
29
Unicode normalization on the local part and on the domain (if originally Unicode). It is the
30
30
concatenation of the local_part and domain attributes, separated by an @-sign."""
31
-
email: str
31
+
normalized: str
32
32
33
33
"""The local part of the email address after Unicode normalization."""
34
34
local_part: str
@@ -68,14 +68,22 @@ def __init__(self, **kwargs):
68
68
setattr(self, k, v)
69
69
70
70
def__repr__(self):
71
-
returnf"<ValidatedEmail {self.email}>"
71
+
returnf"<ValidatedEmail {self.normalized}>"
72
+
73
+
"""For backwards compatibility, support old field names."""
74
+
def__getattr__(self, key):
75
+
ifkey=="original_email":
76
+
returnself.original
77
+
ifkey=="email":
78
+
returnself.normalized
79
+
raiseAttributeError()
72
80
73
81
"""For backwards compatibility, some fields are also exposed through a dict-like interface. Note
74
82
that some of the names changed when they became attributes."""
75
83
def__getitem__(self, key):
76
84
warnings.warn("dict-like access to the return value of validate_email is deprecated and may not be supported in the future.", DeprecationWarning, stacklevel=2)
0 commit comments