Skip to content

fix(ro/cnp): accept county codes 70 and 80-83 to match python-stdnum - #170

Open
vicuts wants to merge 1 commit into
koblas:mainfrom
vicuts:fix/ro-cnp-county-70
Open

vicuts wants to merge 1 commit into
koblas:mainfrom
vicuts:fix/ro-cnp-county-70

Conversation

@vicuts

@vicuts vicuts commented Oct 4, 2026

Copy link
Copy Markdown

Problem

RO.cnp rejects CNPs that use the county code 70, which Romania now issues.

Since 2024, CNPs generated automatically by the Integrated Information System for civil status documents carry the single code 70 in the county position (digits 8 and 9), whatever the place of birth. The Ministry of Internal Affairs confirmed this in a statement from 11 May 2024:
https://www.mai.gov.ro/precizari-in-ceea-ce-priveste-generarea-codului-numeric-personal/

src/ro/cnp.ts only knows the codes 01 to 48, 51 and 52, so every one of these numbers fails with InvalidComponent, even when the date and check digit are correct.

const { stdnum } = require('stdnum');

stdnum.RO.cnp.validate('5240512700014');
// => { isValid: false, error: InvalidComponent }   should be valid

Fix

Add the missing codes to the COUNTIES map, exactly as python-stdnum does in stdnum/ro/cnp.py:

  • 70: any registration, regardless of county
  • 80, 81, 82, 83: listed as valid by several sources, meaning unclear

Upstream change: arthurdejong/python-stdnum@7a9b852 ("Mark more Romanian CNP county codes as valid", closes arthurdejong/python-stdnum#489, released in 2.2). The labels Any and Unknown are the same as upstream.

No other logic changes. Unknown codes such as 99 are still rejected.

Tests

Added four cases to src/ro/cnp.spec.ts:

  • 5240512700014: county 70, valid
  • 5240512700013: same number with a wrong check digit, InvalidChecksum
  • 5240512830010: county 83, valid
  • 1630615993454: county 99, still InvalidComponent (same example as the python-stdnum doctest)

The check digits were verified by hand and against python-stdnum's validate().

npm run lint passes, and npm test passes with TZ=UTC (as in CI). In a UTC+3 timezone, src/mx/curp.spec.ts (getBirthDate) fails locally. It fails on main too and is unrelated to this change.

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.

Romanian TIN - new county codes 70, 80-83 not supported

1 participant