Skip to content

Add ISMN validator and test cases - #2952

Open
SiriKatta0701 wants to merge 1 commit into
validatorjs:masterfrom
SiriKatta0701:feature/add-ismn-validator
Open

SiriKatta0701 wants to merge 1 commit into
validatorjs:masterfrom
SiriKatta0701:feature/add-ismn-validator

Conversation

@SiriKatta0701

Copy link
Copy Markdown

What I Changed

For this issue, I added a new ISMN validator to check whether a number follows the correct format and has a valid check digit. I made it work with both the newer 13-digit ISMNs and the older ones that start with M.

I also added support for spaces and hyphens, while making sure the input doesn't have extra separators at the beginning, end, or repeated together.

Testing

I added 32 test inputs to check different valid and invalid ISMNs. These include numbers with incorrect check digits, wrong prefixes, incorrect lengths, and invalid characters. I also tested both the newer and older ISMN formats.

After making the changes, I ran the full test suite and all 324 tests passed.

Files Updated

  • Added isISMN.js with the new validation function.
  • Updated src/index.js so the validator can be used in the library.
  • Added my test cases in test/validators.test.js.
  • Updated the README to explain the new validator.

Related to #2744.

@codecov

codecov Bot commented Nov 3, 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 (42975e4).

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2952   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          114       115    +1     
  Lines         2599      2618   +19     
  Branches       658       663    +5     
=========================================
+ Hits          2599      2618   +19     

☔ 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