diff options
| author | Ramiro Morales <cramm0@gmail.com> | 2011-06-25 12:39:29 +0000 |
|---|---|---|
| committer | Ramiro Morales <cramm0@gmail.com> | 2011-06-25 12:39:29 +0000 |
| commit | 219a79421745b90b2e8976b7a83c3435c337237f (patch) | |
| tree | b938740c7e4b36a55dcf657481ad10204cbd86c2 | |
| parent | 53a25206c2728585c7410d572f3e88041edf16ba (diff) | |
Fixed #16338 -- Fixed Austrian postal codes validation. Thanks Bernhard Essl for the report and patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16447 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/contrib/localflavor/at/forms.py | 4 | ||||
| -rw-r--r-- | docs/ref/contrib/localflavor.txt | 3 | ||||
| -rw-r--r-- | tests/regressiontests/forms/localflavor/at.py | 2 |
3 files changed, 6 insertions, 3 deletions
diff --git a/django/contrib/localflavor/at/forms.py b/django/contrib/localflavor/at/forms.py index 52721368e0..262641bf1f 100644 --- a/django/contrib/localflavor/at/forms.py +++ b/django/contrib/localflavor/at/forms.py @@ -16,13 +16,13 @@ class ATZipCodeField(RegexField): """ A form field that validates its input is an Austrian postcode. - Accepts 4 digits. + Accepts 4 digits (first digit must be greater than 0). """ default_error_messages = { 'invalid': _('Enter a zip code in the format XXXX.'), } def __init__(self, max_length=None, min_length=None, *args, **kwargs): - super(ATZipCodeField, self).__init__(r'^\d{4}$', + super(ATZipCodeField, self).__init__(r'^[1-9]{1}\d{3}$', max_length, min_length, *args, **kwargs) class ATStateSelect(Select): diff --git a/docs/ref/contrib/localflavor.txt b/docs/ref/contrib/localflavor.txt index d4c9dca495..1e565a58b1 100644 --- a/docs/ref/contrib/localflavor.txt +++ b/docs/ref/contrib/localflavor.txt @@ -243,7 +243,8 @@ Austria (``at``) .. class:: at.forms.ATZipCodeField - A form field that validates its input as an Austrian zip code. + A form field that validates its input as an Austrian zip code, with the + format XXXX (first digit must be greater than 0). .. class:: at.forms.ATStateSelect diff --git a/tests/regressiontests/forms/localflavor/at.py b/tests/regressiontests/forms/localflavor/at.py index 3fa50ac4df..11e0cd4ec1 100644 --- a/tests/regressiontests/forms/localflavor/at.py +++ b/tests/regressiontests/forms/localflavor/at.py @@ -28,6 +28,8 @@ class ATLocalFlavorTests(LocalFlavorTestCase): '8020': '8020', } invalid = { + '0000' : error_format, + '0123' : error_format, '111222': error_format, 'eeffee': error_format, } |
