Skip to content

Conversation

@jesroffrouk
Copy link

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

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable)
  • Tests written (where applicable)
  • References provided in PR (where applicable)

@codecov
Copy link

codecov bot commented Dec 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (784e52a) to head (c935758).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2643   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines         2572      2572           
  Branches       651       651           
=========================================
  Hits          2572      2572           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rubiin rubiin changed the title feat(isPassportNumber): Fixed regex for Mexico fix(isPassportNumber): Fixed regex for Mexico Dec 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants