diff --git a/django/contrib/localflavor/pl/forms.py b/django/contrib/localflavor/pl/forms.py
index 8b4d2f4..35d7e87 100644
a
|
b
|
class PLNationalIDCardNumberField(RegexField):
|
119 | 119 | class PLNIPField(RegexField): |
120 | 120 | """ |
121 | 121 | A form field that validates as Polish Tax Number (NIP). |
122 | | Valid forms are: XXX-XXX-YY-YY or XX-XX-YYY-YYY. |
| 122 | Valid forms are: XXX-YYY-YY-YY, XXX-YY-YY-YYY or XXXYYYYYYY. |
123 | 123 | |
124 | 124 | Checksum algorithm based on documentation at |
125 | 125 | http://wipos.p.lodz.pl/zylla/ut/nip-rego.html |
126 | 126 | """ |
127 | 127 | default_error_messages = { |
128 | | 'invalid': _(u'Enter a tax number field (NIP) in the format XXX-XXX-XX-XX or XX-XX-XXX-XXX.'), |
| 128 | 'invalid': _(u'Enter a tax number field (NIP) in the format XXX-XXX-XX-XX, XXX-XX-XX-XXX or XXXXXXXXXX.'), |
129 | 129 | 'checksum': _(u'Wrong checksum for the Tax Number (NIP).'), |
130 | 130 | } |
131 | 131 | |
132 | 132 | def __init__(self, max_length=None, min_length=None, *args, **kwargs): |
133 | | super(PLNIPField, self).__init__(r'^\d{3}-\d{3}-\d{2}-\d{2}$|^\d{2}-\d{2}-\d{3}-\d{3}$', |
| 133 | super(PLNIPField, self).__init__(r'^\d{3}-\d{3}-\d{2}-\d{2}$|^\d{3}-\d{2}-\d{2}-\d{3}$|^\d{10}$', |
134 | 134 | max_length, min_length, *args, **kwargs) |
135 | 135 | |
136 | 136 | def clean(self,value): |
diff --git a/docs/ref/contrib/localflavor.txt b/docs/ref/contrib/localflavor.txt
index f6dab64..0a97615 100644
a
|
b
|
Poland (``pl``)
|
786 | 786 | |
787 | 787 | .. class:: pl.forms.PLNIPField |
788 | 788 | |
789 | | A form field that validates input as a Polish Tax Number (NIP). Valid |
790 | | formats are XXX-XXX-XX-XX or XX-XX-XXX-XXX. The checksum algorithm used |
| 789 | A form field that validates input as a Polish Tax Number (NIP). Valid formats |
| 790 | are XXX-XXX-XX-XX, XXX-XX-XX-XXX or XXXXXXXXXX. The checksum algorithm used |
791 | 791 | for NIPs is documented at http://wipos.p.lodz.pl/zylla/ut/nip-rego.html. |
792 | 792 | |
793 | 793 | .. class:: pl.forms.PLCountySelect |
diff --git a/tests/regressiontests/forms/localflavor/pl.py b/tests/regressiontests/forms/localflavor/pl.py
index 7225abe..7f4069c 100644
a
|
b
|
class PLLocalFlavorTests(LocalFlavorTestCase):
|
420 | 420 | self.assertFieldOutput(PLPostalCodeField, valid, invalid) |
421 | 421 | |
422 | 422 | def test_PLNIPField(self): |
423 | | error_format = [u'Enter a tax number field (NIP) in the format XXX-XXX-XX-XX or XX-XX-XXX-XXX.'] |
| 423 | error_format = [u'Enter a tax number field (NIP) in the format XXX-XXX-XX-XX, XXX-XX-XX-XXX or XXXXXXXXXX.'] |
424 | 424 | error_checksum = [u'Wrong checksum for the Tax Number (NIP).'] |
425 | 425 | valid = { |
426 | | '64-62-414-124': '6462414124', |
427 | 426 | '646-241-41-24': '6462414124', |
| 427 | '646-24-14-124': '6462414124', |
| 428 | '6462414124': '6462414124', |
428 | 429 | } |
429 | 430 | invalid = { |
430 | 431 | '43-343-234-323': error_format, |
| 432 | '64-62-414-124': error_format, |
431 | 433 | '646-241-41-23': error_checksum, |
432 | 434 | } |
433 | 435 | self.assertFieldOutput(PLNIPField, valid, invalid) |