Opened 5 years ago

Closed 5 years ago

#17544 closed Bug (invalid)

PL localflavor field PLNIPfield allows improper values

Reported by: jbl1 Owned by: nobody
Component: contrib.localflavor Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


One such value is "1112025170":

>>> from import forms
>>> form = forms.PLNIPField()
>>> bool(form.has_valid_checksum("1112025170"))

whereas it is not a valid NIP (tax id number) as the checksum for it is equal 10. All such numbers are not valid formally.

Attaching the simplest possible patch.

Attachments (2)

forms.patch (417 bytes) - added by jbl1 5 years ago.
Patch for django/contrib/localflavor/pl/forms (#17544)
ticket17544.diff (1.1 KB) - added by jbl1 5 years ago.
Patch and regression test for #17544

Download all attachments as: .zip

Change History (4)

Changed 5 years ago by jbl1

Patch for django/contrib/localflavor/pl/forms (#17544)

comment:1 Changed 5 years ago by claudep

  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted

Thanks for reporting. Please could you improve your patch with a test? See changeset:17346 for tips to how the test should be written.

Changed 5 years ago by jbl1

Patch and regression test for #17544

comment:2 Changed 5 years ago by jbl1

  • Has patch unset
  • Needs tests unset
  • Resolution set to invalid
  • Status changed from new to closed

I am sorry. The validation is correct: NIP numbers with checksum = 10 are properly recognized as invalid. My example in the initial report has the checksum = 0 which is correct. Sorry for the noise. NB the prompt for a test case made me realize my error -- many thanks.

Note: See TracTickets for help on using tickets.
Back to Top