koblas / stdnum-js

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

Mexico CURP might need minor corrections #44

Closed teebu closed 1 year ago

teebu commented 1 year ago

Taken from: https://en.wikipedia.org/wiki/Unique_Population_Registry_Code If any step in the above procedure leads to the letter "Ñ" appearing anywhere in the CURP, the "Ñ" is replaced by an "X".

A one-letter gender indicator (H for male (hombre in Spanish), M for female (mujer in Spanish), or X for non-binary); [1]

However, I can't seem to find official documentation for this.

koblas commented 1 year ago

That is an important consideration if you're building CURPs, but stdnum is a validator.

In that case Ñ would be in somebodies name (e.g. Enrique Peña Nieto) but once it's converted to a CURP it would be an X so the validator only needs to know how to handle X in a CURP not the conversion of Ñ => X.

For now, I'm closing this since I don't understand the issue you're trying to describe. If I'm misunderstanding please let me know.

teebu commented 1 year ago

Ok, how about the non-binary X for the gender check?

koblas commented 1 year ago

Similar statements would apply. Since the CURP is the encoding of these fields as long as it was originally encoded correctly there should be no issue with validating the CURP.

That said, reviewing the code getGender() will return the wrong gender for 'X'.

koblas commented 1 year ago

Fixed in #47