Skip to content

feat: add ISBN-10 and ISBN-13 detection#40

Merged
melihbirim merged 1 commit intomainfrom
feat/add-isbn-detection
Dec 27, 2025
Merged

feat: add ISBN-10 and ISBN-13 detection#40
melihbirim merged 1 commit intomainfrom
feat/add-isbn-detection

Conversation

@melihbirim
Copy link
Copy Markdown
Owner

Summary

Adds support for detecting ISBN (International Standard Book Number) in both ISBN-10 and ISBN-13 formats.

Changes

ISBN Detection

  • Added ISBN constant to DataTypes
  • Added ISBN regex pattern supporting both formats with/without hyphens
  • Implemented isISBN() function with JSDoc
  • Added ISBN to TYPE_PRIORITY (after UUID for specificity)
  • Added ISBN to JSON_SCHEMA_TYPE_MAP and JSON_SCHEMA_PATTERN_MAP

Smart Number Detection

  • Added logic to prevent ISBN-like digit sequences (10-13 digits) from being incorrectly detected as numbers
  • Ensures ISBNs are detected before falling through to number detection

Test Coverage

  • 5 comprehensive test cases covering:
    • ISBN-13 with hyphens: 978-0-596-52068-7
    • ISBN-10 with hyphens: 0-596-52068-9
    • ISBNs without hyphens: 9780596520687, 0596520689
    • ISBN-10 with X checksum: 043942089X, 155860832X
    • Invalid ISBN formats properly rejected

Documentation & Types

  • Updated TypeScript definitions in index.d.ts
  • Added ISBN examples to README
  • Updated test count to 104+

Validation

  • ✅ All 104 tests passing
  • npm run lint clean
  • ✅ SEMVER functionality preserved (not removed)
  • ✅ No package-lock.json changes

Attribution

Feature implementation based on work by @riazation42 from PR #35, cleaned up to add ISBN alongside existing types without removing SEMVER.

Closes #14

Add support for detecting ISBN (International Standard Book Number) formats:
- Supports ISBN-10 and ISBN-13
- Handles formats with or without hyphens
- Handles X checksum in ISBN-10
- Prevents ISBN-like digit sequences from being detected as numbers

Changes:
- Added ISBN constant to DataTypes
- Added ISBN pattern to PATTERNS
- Added isISBN() function
- Added ISBN to TYPE_PRIORITY, JSON_SCHEMA_TYPE_MAP, and JSON_SCHEMA_PATTERN_MAP
- Added comprehensive ISBN tests (5 test cases)
- Updated TypeScript definitions
- Updated README with ISBN examples

Co-authored-by: riazation42 <mkhanriaz42@gmail.com>
@melihbirim melihbirim merged commit 4c10c10 into main Dec 27, 2025
8 checks passed
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.

Add ISBN Detector

2 participants