fix: validate CNP unique county code - #26
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes CNP validation regression (Issue #25) by recognizing the “unique county code” (70) and by correctly resolving two-digit county codes with leading zeros (e.g. "09") against the existing numeric-keyed county list.
Changes:
- Added county code
70(“Cod unic”) to the county list. - Updated county parsing/validation to normalize county codes for lookup (supporting
"09"→9). - Added regression tests covering
70CNP validation and"09"county parsing/validation.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/Parser.test.js | Adds a regression test ensuring a CNP containing county code 70 validates successfully. |
| test/countyParser.test.js | Adds tests for parsing/validating two-digit county codes ("09") and the unique county code ("70"). |
| src/countyParser.js | Implements normalization-based lookup to support two-digit county codes and 70. |
| src/countyList.js | Adds county entry for code 70 (“Cod unic”). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+3
to
+7
| const normalizeCountyCode = (countyCode) => { | ||
| const normalized = parseInt(countyCode, 10); | ||
|
|
||
| return Number.isNaN(normalized) ? countyCode : String(normalized); | ||
| }; |
Comment on lines
+64
to
+66
| it(`should return 'true' if county is the unique registration code`, () => { | ||
| expect(countyValidator("70")).to.be.true; | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed the issue that I just reported: #25