Skip to content

Commit

Permalink
Merge 0ae2794 into 5915115
Browse files Browse the repository at this point in the history
  • Loading branch information
jace committed Aug 5, 2020
2 parents 5915115 + 0ae2794 commit 10c4797
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions baseframe/forms/validators.py
Expand Up @@ -387,6 +387,8 @@ class ValidEmail(object):
:param str message: Optional validation error message.
"""

default_message = __("This email address does not appear to be valid")

def __init__(self, message=None):
self.message = message

Expand All @@ -395,10 +397,12 @@ def __call__(self, form, field):
diagnosis = is_email(field.data, check_dns=True, diagnose=True)
except (dns.resolver.Timeout, dns.resolver.NoNameservers):
return
if diagnosis.code == 0:
if diagnosis.code in (0, 3, 4): # 0 is valid, 3 is DNS No NS, 4 is DNS timeout
return
else:
raise StopValidation(self.message or _(diagnosis.message))
raise StopValidation(
self.message or diagnosis.message or self.default_message
)


# Legacy name
Expand Down

0 comments on commit 10c4797

Please sign in to comment.