Skip to content

feat: ISBN-10 and ISBN-13 validation (IGO-10)#100

Merged
strider2038 merged 1 commit into
mainfrom
cursor/-bc-c58494ce-4e16-470f-b1cf-416a5d92595d-1ca1
Apr 7, 2026
Merged

feat: ISBN-10 and ISBN-13 validation (IGO-10)#100
strider2038 merged 1 commit into
mainfrom
cursor/-bc-c58494ce-4e16-470f-b1cf-416a5d92595d-1ca1

Conversation

@strider2038
Copy link
Copy Markdown
Contributor

Summary

Adds ISBN validation aligned with Symfony Isbn / IsbnValidator: strip hyphens, ISBN-10 (with X check digit) and ISBN-13 checksums, and “any” mode that maps 11–12 digit lengths to a type-not-recognized outcome like Symfony’s combined tests.

API

  • validate.ISBN, validate.ISBNOnly10, validate.ISBNOnly13 with sentinel errors (ErrISBNInvalidCharacters, ErrISBNTooShort, ErrISBNTooLong, ErrISBNChecksumFailed, ErrISBNTypeNotRecognized)
  • it.IsISBN() with Only10() / Only13(), optional WithISBN10Message, WithISBN13Message, WithBothISBNMessage, and matching error overrides
  • is.ISBN
  • Messages: message.InvalidISBN, InvalidISBN10, InvalidISBN13 (+ EN/RU catalogs), validation.ErrInvalidISBN, ErrInvalidISBN10, ErrInvalidISBN13

Testing

  • Table tests in validate/isbn_test.go (Symfony test vectors)
  • Shared constraint cases in test/constraints_identifiers_cases_test.go
  • Examples in it, validate, and is packages

Changelog

  • Entry under [Unreleased] → Added

Linear: IGO-10

Open in Web Open in Cursor 

- validate.ISBN with ISBNOnly10/ISBNOnly13 and sentinel errors
- it.IsISBN with Only10/Only13 and per-mode messages/errors
- is.ISBN helper; EN/RU translations; tests and examples

Closes IGO-10.

Co-authored-by: Igor Lazarev <strider2038@yandex.ru>
@strider2038 strider2038 marked this pull request as ready for review April 7, 2026 16:39
@strider2038 strider2038 merged commit 055465f into main Apr 7, 2026
2 checks passed
@strider2038 strider2038 deleted the cursor/-bc-c58494ce-4e16-470f-b1cf-416a5d92595d-1ca1 branch April 7, 2026 16:45
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.

2 participants