Opened 10 years ago

Closed 10 years ago

#23224 closed Bug (fixed)

Document EmailValidator domain whitelist parameter

Reported by: egberts Owned by: nobody
Component: Documentation Version: 1.7-alpha-2
Severity: Normal Keywords: SMTP email syntax
Cc: areski@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I am unable to validate "webmaster@lab" email address using EmailField() validator.

Examination of Test framework (TEST_DATA in tests.py) shows that it won't take the "abc@bar" email format.

TEST_DATA =
...
 (validate_email, 'abc@bar', ValidationError)
...

Did I miss something new amongst the vast IETF specifications regarding this new restrictive email syntax? Or must we expand our 20yo Lab domain name to something like 'lab.test'?

Tarball File Used: django-django-1.7a3-1364-gedcc75e.zip

Change History (6)

comment:1 by Collin Anderson, 10 years ago

as a data point: yes, django 1.6 gives the same error message

>>> from django import forms
>>> forms.EmailField().clean('webmaster@lab')
ValidationError: [u'Enter a valid email address.']

comment:2 by Areski Belaid, 10 years ago

Cc: areski@… added

FYI this is where django implement the email validation: https://github.com/django/django/blob/master/django/core/validators.py#L119
documentation on validators: https://docs.djangoproject.com/en/dev/ref/forms/validation/#using-validation-in-practice

From this, you will notice that there is an easy way to validate abc@bar:

from django.forms import EmailField
from django.core.validators import EmailValidator

class MyEmailField(EmailField):
    default_validators = [EmailValidator(whitelist=['bar'])]

MyEmailField().clean('abc@bar')

comment:3 by Tim Graham, 10 years ago

Component: Testing frameworkDocumentation
Summary: Unable to validate "webmaster@lab" via EmailField() validationDocument EmailValidator domain whitelist parameter
Triage Stage: UnreviewedAccepted

We should document the solution described by areski.

comment:4 by Areski Belaid, 10 years ago

Here a PR for to document the solution https://github.com/django/django/pull/3056

Last edited 10 years ago by Areski Belaid (previous) (diff)

comment:5 by Tim Graham, 10 years ago

Has patch: set

comment:6 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: newclosed

In 2a4492aecb50122f7cc2c643f7ea5b086f301165:

Fixed #23224 - Documented EmailValidator.

Note: See TracTickets for help on using tickets.
Back to Top