Skip to content

Instantly share code, notes, and snippets.

@doismellburning
Created February 20, 2012 14:25
Show Gist options
  • Save doismellburning/1869463 to your computer and use it in GitHub Desktop.
Save doismellburning/1869463 to your computer and use it in GitHub Desktop.
Django 1.3.1 EmailValidator
email_re = re.compile(
r"(^[-!#$%&'*+/=?^_`{}|~0-9A-Z]+(\.[-!#$%&'*+/=?^_`{}|~0-9A-Z]+)*" # dot-atom
r'|^"([\001-\010\013\014\016-\037!#-\[\]-\177]|\\[\001-011\013\014\016-\177])*"' # quoted-string
r')@(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?$', re.IGNORECASE) # domain
validate_email = EmailValidator(email_re, _(u'Enter a valid e-mail address.'), 'invalid')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment