mirror of
https://github.com/django/django.git
synced 2025-11-25 05:04:26 +00:00
newforms: Fixed unexpected behavior with CharField(required=False, min_length=X). Thanks for reporting, Benjamin Slavin
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4217 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
4f5170bffe
commit
26489d4e2a
2 changed files with 16 additions and 1 deletions
|
|
@ -687,9 +687,21 @@ ValidationError: [u'Ensure this value has at most 10 characters.']
|
|||
CharField accepts an optional min_length parameter:
|
||||
>>> f = CharField(min_length=10, required=False)
|
||||
>>> f.clean('')
|
||||
u''
|
||||
>>> f.clean('12345')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
ValidationError: [u'Ensure this value has at least 10 characters.']
|
||||
>>> f.clean('1234567890')
|
||||
u'1234567890'
|
||||
>>> f.clean('1234567890a')
|
||||
u'1234567890a'
|
||||
|
||||
>>> f = CharField(min_length=10, required=True)
|
||||
>>> f.clean('')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
ValidationError: [u'This field is required.']
|
||||
>>> f.clean('12345')
|
||||
Traceback (most recent call last):
|
||||
...
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue