diff options
| author | Adrian Holovaty <adrian@holovaty.com> | 2006-11-27 00:23:17 +0000 |
|---|---|---|
| committer | Adrian Holovaty <adrian@holovaty.com> | 2006-11-27 00:23:17 +0000 |
| commit | 2e4ff8ee0c0319a5c67c3fc4c4430e56562dfa53 (patch) | |
| tree | 9a6f963094e35876b0de9232d659b2215e26eeb1 /tests/regressiontests/forms | |
| parent | d1757daf0fa264fa2fb3a8d41848d74b228c4c22 (diff) | |
Fixed #3038 -- newforms: RegexField no longer validates empty input for required=False. Thanks for reporting, Thomas Steinacher
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4111 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/forms')
| -rw-r--r-- | tests/regressiontests/forms/tests.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/tests/regressiontests/forms/tests.py b/tests/regressiontests/forms/tests.py index 0ef3e810fc..8e7f057e4f 100644 --- a/tests/regressiontests/forms/tests.py +++ b/tests/regressiontests/forms/tests.py @@ -484,13 +484,13 @@ u'1' u'hello' >>> f.clean(None) u'' +>>> f.clean('') +u'' >>> f.clean([1, 2, 3]) u'[1, 2, 3]' CharField accepts an optional max_length parameter: >>> f = CharField(max_length=10, required=False) ->>> f.clean('') -u'' >>> f.clean('12345') u'12345' >>> f.clean('1234567890') @@ -700,6 +700,22 @@ ValidationError: [u'Enter a valid value.'] Traceback (most recent call last): ... ValidationError: [u'Enter a valid value.'] +>>> f.clean('') +Traceback (most recent call last): +... +ValidationError: [u'This field is required.'] + +>>> f = RegexField('^\d[A-F]\d$', required=False) +>>> f.clean('2A2') +u'2A2' +>>> f.clean('3F3') +u'3F3' +>>> f.clean('3G3') +Traceback (most recent call last): +... +ValidationError: [u'Enter a valid value.'] +>>> f.clean('') +u'' Alternatively, RegexField can take a compiled regular expression: >>> f = RegexField(re.compile('^\d[A-F]\d$')) |
