Code

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#2129 closed defect (invalid)

the validate() method shouldn't ignore maxlength

Reported by: tom@… Owned by: adrian
Component: Validators Version: master
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The validate() method of a model does not complain when exceeding the maxlength of a CharField.
There should be an error in the returned dictionary (e.g. "Ensure your text is less than 75 characters.")

In the following example someone could add an invalid e-mail-address without getting a validation error:

>>> import django.contrib.auth.models as auth
>>> u = auth.User.objects.get(pk=1)
>>> u.email = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@xx.xx'
>>> u.validate()
{}
>>> u.save()
/usr/lib/python2.3/site-packages/django/db/backends/mysql/base.py:35: Warning: Rows matched: 1  Changed: 1  Warnings: 1
  return self.cursor.execute(sql, params)
>>> u.validate()
{}
>>> u = auth.User.objects.get(pk=1)
>>> u.email
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
>>> u.validate()
{'email': ['Enter a valid e-mail address.']}
>>> 

Attachments (0)

Change History (1)

comment:1 Changed 8 years ago by adrian

  • Resolution set to invalid
  • Status changed from new to closed

validate() isn't meant to be public yet, and it's not finished yet, so I'm closing this.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.