django / django-localflavor

Country-specific Django helpers, formerly of contrib fame
https://django-localflavor.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
813 stars 289 forks source link

Fix MX curp field #449

Closed quevon24 closed 2 years ago

quevon24 commented 2 years ago

Correct regex to validate MX CURP is:

curp_re = (r'^[A-Z][AEIOUX][A-Z]{2}%s[HM]%s%s{3}[0-9A-Z]\d$' %
                   (DATE_RE, states_re, consonants_re))

It needs an X because the second character is the first vowel of the first last name(surname), in the case that there is no vowel, CURP comes with an X, e.g: For example mayan last name 'OY'() second char is a consonant, not vowel, so the the beginning of the curp it's OX and it's not valid with actual regex.

benkonrath commented 2 years ago

Thanks for the PR. A couple of points:

Thanks again for the fix!

quevon24 commented 2 years ago

Thanks, I commited the new changes with what you ask for. I added an example to test_MXCURPField and the new entry on changelog.

And thanks for this incredible package. 👍

benkonrath commented 2 years ago

Thanks! :hand: (high five)