Skip to content

fix: support two-letter Australian passport prefixes in src/lib/isPassportNumber.js - #2981

Open
stackdev-ash wants to merge 1 commit into
validatorjs:masterfrom
stackdev-ash:fix/2979-au-passport-regex
Open

stackdev-ash wants to merge 1 commit into
validatorjs:masterfrom
stackdev-ash:fix/2979-au-passport-regex

Conversation

@stackdev-ash

Copy link
Copy Markdown

Description

Updates the Australian passport number regex to support both single-letter and two-letter prefixes followed by seven digits.

The existing regex rejects newer R-series Australian passport numbers.

Changes

  • Updated the AU regex from /^[A-Z]\d{7}$/ to /^[A-Z]{1,2}\d{7}$/.
  • Added regression tests for newer Australian passport formats.
  • Preserved backward compatibility and existing lowercase and whitespace normalization.
  • Added negative test cases for malformed passport numbers.

Reference

The Australian Government's Digital ID (AGDIS) Data Standards 2024, Section 2.1.4.9, specifies one or two alphabetic characters followed by seven numeric characters.

https://www.legislation.gov.au/F2024L01443/asmade/2024-11-13/text/original/epub/OEBPS/document_1/document_1.html

Testing

  • Reproduced the reported bug before implementing the fix: 322 passing, 1 failing.
  • After implementing the fix: 323 passing, 0 failing.
  • Existing code coverage remains unchanged.

Closes #2979

@codecov

codecov Bot commented Dec 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (9ff3424) to head (f338b84).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2981   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       114           
  Lines         2599      2599           
  Branches       658       658           
=========================================
  Hits          2599      2599           

☔ View full report in Codecov by Harness.
📢 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.

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.

Correct AU regex for isPassportNumber

1 participant