fix(isPassportNumber): improve `US` locale by yitzchak-schechter · Pull Request #2550 · validatorjs/validator.js

Skip to content

Navigation Menu

Sign in

Appearance settings

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

Conversation

@yitzchak-schechter

Copy link Copy Markdown

Contributor

Update isPassportNumber to include new US passport number alphanumeric format

In the Next Generation US Passport, the passport number begins with a letter, followed by eight numbers.

  • Regex updated to support both old and new patterns:
    • Old: 9 digits, /^\d{9}$/
    • New: 1 letter + 8 digits, /^[A-Z]\d{8}$/
    • Combined: /^\d{9}$|^[A-Z]\d{8}$/
  • Added test cases for the new pattern.

Source: Information about the Next Generation U.S. Passport - travel.state.gov

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 Copy Markdown

codecov bot commented

Apr 9, 2025

edited

Loading

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (fde5ed5) to head (dd56325).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2550   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines         2535      2535           
  Branches       641       641           
=========================================
  Hits          2535      2535           

☔ 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.

@WikiRik WikiRik changed the title fix(isPassportNumber): improve US fix(isPassportNumber): improve US locale

Apr 9, 2025

@WikiRik WikiRik requested a review from rubiin

April 9, 2025 10:25

@rubiin rubiin merged commit bdb8f9e into validatorjs:master

Apr 9, 2025

13 checks passed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@rubiin rubiin rubiin approved these changes

@WikiRik WikiRik WikiRik approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@yitzchak-schechter @rubiin @WikiRik