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
This commit is contained in:
Ramiro Morales 2011-06-25 12:39:29 +00:00
parent 53a25206c2
commit 219a794217
3 changed files with 6 additions and 3 deletions

View File

@ -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 File

@ -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 File

@ -28,6 +28,8 @@ class ATLocalFlavorTests(LocalFlavorTestCase):
'8020': '8020',
}
invalid = {
'0000' : error_format,
'0123' : error_format,
'111222': error_format,
'eeffee': error_format,
}