Indeed, name@mail.56 email is a valid email address for django EmailValidator , does not see errors:
>>> from django.core.validators import validate_email >>> validate_email("name@mail.56") >>>
Django (1.5.1) uses the following regular expression to validate an email address:
r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*" # dot-atom # quoted-string, see also http://tools.ietf.org/html/rfc2822#section-3.2.5 r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-\011\013\014\016-\177])*"' r')@((?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[AZ]{2,6}\.?|[A-Z0-9-]{2,}\.?)$)' # domain r'|\[(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}\]$'
And it actually complies with the RFC2822 standard.
If you want to make name@mail.56 crash during validation, you can create your own validator and add it to EmailField validators with the built-in validate_email validator, for example:
from django.core.validators import validate_email from django.core.exceptions import ValidationError def custom_validate_email(value): if <custom_check>: raise ValidationError('Email format is incorrect') ... email = models.EmailField(max_length=254, blank=False, unique=True, validators=[validate_email, custom_validate_email)
And, FYI, you can always submit a ticket to the django ticket system or ask about a problem on the IRC django channel (irc: //irc.freenode.net/django).
See also: Writing Validators .
Hope this helps.
alecxe
source share