Opened 16 years ago
Closed 12 years ago
#10204 closed Bug (invalid)
Validation fails in spanish localflavor ESIdentityCardNumberField
Reported by: | Pablo Suárez Hdez. | Owned by: | Pablo Suárez Hdez. |
---|---|---|---|
Component: | contrib.localflavor | Version: | dev |
Severity: | Normal | Keywords: | ESIdentityCardNumberField, NIE, localflavorsplit |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
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 (4)
Change History (20)
by , 16 years ago
Attachment: | spanish_nie.patch added |
---|
comment:1 by , 16 years ago
Status: | new → assigned |
---|
comment:2 by , 16 years ago
Component: | Uncategorized → django.contrib.localflavor |
---|---|
Has patch: | set |
comment:3 by , 16 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:4 by , 16 years ago
Keywords: | ESIdentityCardNumberField NIE added |
---|---|
Triage Stage: | Accepted → Ready for checkin |
comment:5 by , 16 years ago
Triage Stage: | Ready for checkin → Accepted |
---|
comment:6 by , 16 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
comment:7 by , 16 years ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Ready for checkin → 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).
comment:8 by , 16 years ago
Patch needs improvement: | unset |
---|
by , 16 years ago
Attachment: | patch_and_tests_final.diff added |
---|
patch and regressiontests in same file.
comment:9 by , 16 years ago
Patch needs improvement: | set |
---|
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.
comment:10 by , 16 years ago
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].
comment:11 by , 16 years ago
Patch needs improvement: | unset |
---|
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).
comment:12 by , 14 years ago
Excuse me but I didn't know how to notify this.
I am using ESIdentityCardNumberField in django 1.2.
cifs starting with "J" should be valid but none passes validation, I get:
'Please enter a valid NIF, NIE, or CIF.'
In fact it surely fails with cifs starting by J,R,U,V,W according to newest normative.
See here: http://www.boe.es/aeboe/consultas/bases_datos/doc.php?id=BOE-A-2008-3580
I suppose it's just a matter of changing:
self.cif_types = 'ABCDEFGHKLMNPQS' to self.cif_types = 'ABCDEFGHJKLMNPQRSUVW'
comment:13 by , 14 years ago
Patch needs improvement: | set |
---|---|
Severity: | → Normal |
Type: | → Bug |
comment:16 by , 12 years ago
Keywords: | localflavorsplit added |
---|---|
Resolution: | → invalid |
Status: | assigned → closed |
django.contrib.localflavor
is now deprecated — see https://docs.djangoproject.com/en/dev/ref/contrib/localflavor/
A repository was created for each localflavor at https://github.com/django/django-localflavor-? (Replace with the country code.)
If you're still interested in this ticket, could you create a pull request on that repository?
Sorry for not resolving this issue earlier, and thanks for your input!
Not ready for checkin - requires tests (regressiontests/localflavor/es)