Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isPassport does not support new Canadian Passport Number Format #2525

Open
evanbechtol opened this issue Feb 7, 2025 · 0 comments · May be fixed by #2526
Open

isPassport does not support new Canadian Passport Number Format #2525

evanbechtol opened this issue Feb 7, 2025 · 0 comments · May be fixed by #2526

Comments

@evanbechtol
Copy link

Describe the bug
The isPassport function does not support the new Canadian Passport Number format.

Currently, isPassport only supports the old format of: 2 letters, followed by exactly 6 digits, represented by the regex (/^[A-Z]{2}\d{6}$/).

The new Canadian Passport Number format is: 1 letter, 6 numbers, and 2 letters.

Examples
src/lib/isPassportNumber.js line 19
CA: /^[A-Z]{2}\d{6}$/, // CANADA

This regex in English means: the string must start with exactly 2 uppercase letters from A-Z, followed by exactly 6 digits, and then the end of the string.

This could be fixed by modifying the existing regular expression to be: CA: /^[A-Z]{2}\d{6}$|^[A-Z]\d{6}[A-Z]{2}$/, // CANADA

Reproductions
If applicable, provide a reproduction on platforms like runkit

Additional context
Validator.js version: 13.12.0
Node.js version: any
OS platform: any

Sources

  1. https://www.canada.ca/en/immigration-refugees-citizenship/services/canadian-passports/new-passport-features.html
  2. https://en.wikipedia.org/wiki/Canadian_passport#Data_page
  3. https://www.canada.ca/en/immigration-refugees-citizenship/news/2023/05/canada-unveils-new-passport-design-with-state-of-the-art-security-features.html
  4. https://techcommunity.microsoft.com/discussions/azurepurview/feature-request-dlp-add-new-passport-numbering-format-for-canada/4214263
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants