Skip to content

fix(isPassportNumber): accept South Korea's next-generation passport numbers - #2962

Open
wonjangcloud9 wants to merge 1 commit into
validatorjs:masterfrom
wonjangcloud9:fix/passport-kr-next-generation
Open

wonjangcloud9 wants to merge 1 commit into
validatorjs:masterfrom
wonjangcloud9:fix/passport-kr-next-generation

Conversation

@wonjangcloud9

Copy link
Copy Markdown

Since 21 December 2021, South Korea has issued next-generation passports whose numbers put a letter in the fifth position: M123A4567 instead of M12345678. The KR pattern only allowed eight digits after the type letter, so isPassportNumber rejected every Korean passport issued since then.

This PR keeps the old form and adds the new one: /^[MS](\d{8}|\d{3}[A-Z]\d{4})$/.

Checked against the published build (require('./index.js')):

input master this PR
M12345678 (old format) true true
M123A4567 (new format, the government's own example) false true
m123a4567 (lowercase; the input is upper-cased before matching) false true
S456B7890 false true
M1234A567 (letter in the wrong place) false false
M123A456 (too short) false false
X123A4567 (unknown type letter) false false

The new cases in test/validators.test.js fail on master with validator.isPassportNumber("M123A4567", "KR") failed but should have passed and pass with the fix. The full npm test (build, lint, Mocha) passes: 323 passing.

Scope: I kept the existing M/S type letters. Microsoft's definition also lists R, O and D (residence, official and diplomatic passports). That is a separate change, so I left it out.

References

Checklist

  • PR contains only changes related; no stray files, etc.
  • README updated (where applicable) — not applicable, the country code list is unchanged
  • Tests written (where applicable)
  • References provided in PR (where applicable)

🤖 Generated with Claude Code

…numbers

Since 21 December 2021 Korea issues next-generation passports whose
number puts a letter in the fifth position (M123A4567 instead of
M12345678). The KR pattern only allowed eight digits after the type
letter, so every passport issued since then was rejected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 14, 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 (31c51cd).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2962   +/-   ##
=========================================
  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.

1 participant