validate_email returns None for any or format

377 views
Skip to first unread message

NoviceSortOf

unread,
Dec 20, 2016, 8:28:48 AM12/20/16
to Django users

Why does validate_email return None irregardless of what is typed in?

>>> from django.core.validators import validate_email
>>> x = validators.validate_email('te...@example.com')
>>> print x
None
>>>

Shouldn't it be returning True or False?


Vijay Khemlani

unread,
Dec 20, 2016, 9:26:22 AM12/20/16
to django...@googlegroups.com
As far as I know validators don't return anything, just raise an Exception if the parameters don't validate

On Tue, Dec 20, 2016 at 10:28 AM, NoviceSortOf <dljons...@gmail.com> wrote:

Why does validate_email return None irregardless of what is typed in?

>>> from django.core.validators import validate_email
>>> x = validators.validate_email('test...@example.com')
>>> print x
None
>>>

Shouldn't it be returning True or False?


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a92f05ab-1ad3-4434-8cf8-de3fb8f87d7d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michal Petrucha

unread,
Dec 21, 2016, 7:06:51 AM12/21/16
to django...@googlegroups.com
According to
https://docs.djangoproject.com/en/1.10/ref/forms/validation/#validators:

> A validator is merely a callable object or function that takes a
> value and simply returns nothing if the value is valid or raises a
> ValidationError if not.

Cheers,

Michal
signature.asc

NoviceSortOf

unread,
Dec 21, 2016, 3:31:07 PM12/21/16
to Django users
Thanks, I can build logic on that.


On Tuesday, December 20, 2016 at 2:28:48 PM UTC+1, NoviceSortOf wrote:

Why does validate_email return None irregardless of what is typed in?

>>> from django.core.validators import validate_email
>>> x = validators.validate_email('test...@example.com')
>>> print x
None
>>>
Reply all
Reply to author
Forward
0 new messages