koblas / stdnum-js

A JavaScript library to provide functions to handle, parse and validate standard numbers.
MIT License
39 stars 26 forks source link

Spanish DNI for children and citizens who live outside of Spain #51

Open teebu opened 1 year ago

teebu commented 1 year ago

Based on this document, there are 2 additional formats allowed for DNI with a designated special latter.

I used these sites as refferences: https://www.strongabogados.com/tax-id-spain.php https://docedit.supernaeyeglass.com/articles/#!eyeglass-administration-guides-publication/content-classification-feature-guide/a/h3__54668704 https://www.esma.europa.eu/sites/default/files/library/esma70-1861941480-56_qas_mifir_data_reporting.pdf

DNI (Documento Nacional de Identidad): This is the ID number for Spanish citizens. The DNI format is 8 digits followed by a letter (example: 12345678A). The same number is used for one's driver's license.

There are two other classes of DNI for citizens of Spain: 'K' (example: K12345678A) for children under 14 who are Spanish residents. 'L' (example: L12345678A) for Spanish citizens who live outside Spain.

koblas commented 1 year ago

Looks like it's 7 digits in there.

https://www.oecd.org/tax/automatic-exchange/crs-implementation-and-assistance/tax-identification-numbers/SPAIN-TIN.pdf

koblas commented 1 year ago

Though they're not referenced on the offical documents.

https://www.interior.gob.es/opencms/ca/servicios-al-ciudadano/tramites-y-gestiones/dni/calculo-del-digito-de-control-del-nif-nie/

koblas commented 1 year ago

I've dug around a lot and I cannot find any validation algorithms for the "KLM" code set. I've got two choices:

  1. Just allow them without checksum validation
  2. Wait until some test cases are available

Do you currently have some that you're trying to validate?

teebu commented 1 year ago

No, I dont have any. This is just something I encountered in my research.

Im not clear on the approach. You seem to have done something similar in the other validators.

You did something similar here for NIF https://github.com/koblas/stdnum-js/blob/main/src/es/nif.ts#L65 ?

This site makes it seem like they are just indicators and not part of the checksum? https://www.strongabogados.com/tax-id-spain.php like K12345678A is the same as 12345678A?

Do you think its safe to ignore KL if its present for DNI when validating?

Also here: https://docedit.supernaeyeglass.com/articles/#!eyeglass-administration-guides-publication/content-classification-feature-guide/a/h4_250181372

image