Skip to content

isPassport does not support new Canadian Passport Number Format #2525

@evanbechtol

Description

@evanbechtol

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions