-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
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
- https://www.canada.ca/en/immigration-refugees-citizenship/services/canadian-passports/new-passport-features.html
- https://en.wikipedia.org/wiki/Canadian_passport#Data_page
- https://www.canada.ca/en/immigration-refugees-citizenship/news/2023/05/canada-unveils-new-passport-design-with-state-of-the-art-security-features.html
- https://techcommunity.microsoft.com/discussions/azurepurview/feature-request-dlp-add-new-passport-numbering-format-for-canada/4214263