Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #16338 -- Fixed Austrian postal codes validation. Thanks Bernha…

…rd Essl for the report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16447 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 219a79421745b90b2e8976b7a83c3435c337237f 1 parent 53a2520
@ramiro ramiro authored
View
4 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):
View
3  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
View
2  tests/regressiontests/forms/localflavor/at.py
@@ -28,6 +28,8 @@ def test_ATZipCodeField(self):
'8020': '8020',
}
invalid = {
+ '0000' : error_format,
+ '0123' : error_format,
'111222': error_format,
'eeffee': error_format,
}
Please sign in to comment.
Something went wrong with that request. Please try again.