Repository navigation
[patch] Require the 978/979 Bookland prefix on an ISBN-13 - #407
Merged
Merged
Conversation
IsIsbnAttribute only checked an ISBN-13's mod-10 check digit, which every
EAN-13 barcode passes, so Isbn.Create("4006381333931") accepted a non-book
product code. An ISBN-13 must now start with 978 or 979.
Fixes #334
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LoEzLXruuTHCcJnXtVa49Z
|
This was referenced Oct 9, 2026
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.



Fixes #334
What was wrong
IsIsbnAttributechecked only an ISBN-13's mod-10 check digit. Every EAN-13 barcode passes that check, soIsbn.Create("4006381333931"), a non-book product code, validated as an ISBN.Change (
Semantics.Strings.Identifiers)IsIsbnAttribute.IsValidIsbn13rejects any value that doesn't start with978or979, the Bookland range ISBNs are allocated from. It runs before the checksum.IsIsbnAttributeandIsbnand the rules table in the package README now mention the prefix.Release note: this tightens validation. An
Isbnthat was stored from a non-978/979 EAN-13 will now failCreateandTryCreate.Tests (
IsbnTests)Create_Ean13OutsideBooklandRange_Throws:4006381333931(the issue's example),5901234123457, and9770317847001(an ISSN-style977barcode). Each has a valid EAN-13 check digit and now throwsArgumentException.TryCreate_Ean13OutsideBooklandRange_ReturnsFalse:TryCreatereturnsfalsewith a null result.Create_ValidIsbn13With979Prefix_Succeeds:979-10-90636-07-1still validates, so the979range keeps working.Verification
IsIsbnAttribute.csreverted, the 4 out-of-range cases fail. With the fix, all 12IsbnTestspass.Semantics.Testsuite passes on net10.0: 1485 passed, 0 failed, 8 skipped (the same 8 are skipped onmain).Semantics.Strings.Identifiersbuilds with the local Sonar analyzers (.sonarlint/sonar-local.props) with 0 warnings.🤖 Generated with Claude Code
https://claude.ai/code/session_01LoEzLXruuTHCcJnXtVa49Z
Generated by Claude Code