Django

Code

Ticket #10204 (assigned)

Opened 1 year ago

Last modified 11 months ago

Validation fails in spanish localflavor ESIdentityCardNumberField

Reported by: meaksh Assigned to: meaksh (accepted)
Milestone: Component: django.contrib.localflavor
Version: SVN Keywords: ESIdentityCardNumberField, NIE
Cc: Triage Stage: Accepted
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

The spanish localflavor ESIdentityCardNumberField accepts the syntax of the spanish official cards type, but due the new revision of the law (http://www.boe.es/boe/dias/2008/07/15/pdfs/A30880-30880.pdf), it need to be updated.

Attachments

spanish_nie.patch (0.8 kB) - added by meaksh on 02/06/09 15:57:27.
regressiontests.diff (0.8 kB) - added by meaksh on 02/25/09 09:22:18.
Regressions Tests
patch_and_tests_final.diff (2.2 kB) - added by meaksh on 03/01/09 07:09:35.
patch and regressiontests in same file.
patch_nifniecif_es.diff (2.2 kB) - added by Cesar Ortiz <cesar.ortiz@gmail.com> on 05/06/09 04:34:14.
An alternative (and right) patch

Change History

02/06/09 15:57:27 changed by meaksh

  • attachment spanish_nie.patch added.

02/06/09 15:58:13 changed by meaksh

  • status changed from new to assigned.
  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

02/06/09 15:58:52 changed by meaksh

  • has_patch set to 1.
  • component changed from Uncategorized to django.contrib.localflavor.

02/06/09 16:04:33 changed by meaksh

  • stage changed from Unreviewed to Accepted.

02/06/09 16:16:31 changed by meaksh

  • keywords set to ESIdentityCardNumberField, NIE.
  • stage changed from Accepted to Ready for checkin.

02/22/09 01:25:30 changed by russellm

  • stage changed from Ready for checkin to Accepted.

Not ready for checkin - requires tests (regressiontests/localflavor/es)

02/25/09 09:22:18 changed by meaksh

  • attachment regressiontests.diff added.

Regressions Tests

02/25/09 09:24:56 changed by meaksh

  • stage changed from Accepted to Ready for checkin.

02/28/09 19:37:33 changed by mtredinnick

  • needs_better_patch set to 1.
  • stage changed from Ready for checkin to Accepted.

Please don't mark you own tickets/patches as ready for checkin. As you can see, there are problems that show up in the review and skipping that step isn't a good idea. Just leave the ticket as "accepted" and it will be reviewed in due course.

Please create a single patch containing all the changes so that they can be reviewed in one pass and we don't have to work out which patches need to be applied (particularly if more changes occur before this is applied).

03/01/09 06:43:53 changed by meaksh

  • needs_better_patch deleted.

03/01/09 07:09:35 changed by meaksh

  • attachment patch_and_tests_final.diff added.

patch and regressiontests in same file.

(in reply to: ↑ description ) 05/04/09 12:13:57 changed by Cesar Ortiz <cesar.ortiz@gmail.com>

  • needs_better_patch set to 1.

The 'T' letter is not a valid cif/nif. References: http://es.wikipedia.org/wiki/NIF http://es.wikipedia.org/wiki/C%C3%B3digo_de_identificaci%C3%B3n_fiscal http://es.wikipedia.org/wiki/NIE

Furthemore... to support the XYZ the algorithm must be changed. An '0' (for X), '1' (for the Y), '2' (for Z) should be added at the beggining of the number before the casting to int.

Replying to meaksh:

The spanish localflavor ESIdentityCardNumberField accepts the syntax of the spanish official cards type, but due the new revision of the law (http://www.boe.es/boe/dias/2008/07/15/pdfs/A30880-30880.pdf), it need to be updated.

05/05/09 04:28:21 changed by Cesar Ortiz <cesar.ortiz@gmail.com>

I've been searching about the 'T'... It looks that is used (or has been used) for foreigners when the number in their country match the format of the spanish number.

"La ley establece que el NIF, en caso de personas físicas extranjeras con documentación del pais de origen podrá sustituirse por el número de identidad válido en su país de origen, precedido por una T. Por tanto y de cara a la validación: TODO NIF QUE COMIENCE POR T ES VÁLIDO, dado que el resto del NIF se rige de acuerdo a la legislación propia de cada país"

But I have not found official documentation. So, the validation of that number is not possible because the algorithm is not the spanish one. A decision must be taken in order to support T numbers. Furthemore, the T is treated as an X, what is wrong.

In theory a valid T NIE would be a T followed by 8 characters in the set [A-Z0-9].

05/06/09 04:34:14 changed by Cesar Ortiz <cesar.ortiz@gmail.com>

  • attachment patch_nifniecif_es.diff added.

An alternative (and right) patch

05/06/09 04:37:45 changed by Cesar Ortiz <cesar.ortiz@gmail.com>

  • needs_better_patch deleted.

I just added another patch. I included the code to support YZ NIE types and supressed the T as a NIE type. I don´t think that a NIE T type will appear, is so a new ticket can be opened. I think that the T type should not be consider (anyway the implementation was wrong as a checking should not be done for the T type).


Add/Change #10204 (Validation fails in spanish localflavor ESIdentityCardNumberField)




Change Properties
Action