fix(isPassportNumber): Fixed regex for Mexico #2643
+5
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
issue: #2641
Mexican passport number format changed with the introduction of the biometric electronic passport (ePassport) in October 2021
Passport numbers with 10 or 11 characters are generally considered invalid after their expiry. Until expiry, only 9 alphanumeric characters are considered valid, after excluding the first two characters, which usually represent the year.
in short,
Older passports are still valid and follow a format of one letter followed by eight digits.
Modern ePassports use a 9-character alphanumeric format, usually starting with “G” or “N” series.
Even though, it's alphanumeric I still couldn't find examples where other digits are letters except first.
so my solution is to go for starting with a letter and 8 numbers. It supports both old and new format.
I have changed regex for mexico in isPassportNumber and added some test cases.
source for Mexican Passport change: https://en.wikipedia.org/wiki/Mexican_passport
source for correct validations: https://www.brandeis.edu/isso/travel/form-i94/tips.html
source for examples: https://trustdochub.com/en/verify-mexican-passport/
https://www.microfocus.com/documentation/idol/IDOL_24_3/EductionGrammars_24.3_Documentation/PII/Content/PII/PII_Examples_Passport.htm
Checklist