Skip to content

fix(isbn): accept hyphens and spaces between the parts of an ISBN - #440

Merged
yezz123 merged 1 commit into
pydantic:mainfrom
RavSinghChandan:isbn-hyphens
Oct 12, 2026
Merged

yezz123 merged 1 commit into
pydantic:mainfrom
RavSinghChandan:isbn-hyphens

Conversation

@RavSinghChandan

Copy link
Copy Markdown
Contributor

ISBNs are almost always written with hyphens or spaces between their parts, as on a book's back cover (978-3-16-148410-0, 0-306-40615-2), and ISO 2108 allows either. ISBN rejected these with "Length for ISBN must be 10 or 13 digits, not 17", and a hyphenated ISBN-10 was even checked as an ISBN-13.

The hyphens and spaces are now removed before validating, so these give the same normalised ISBN-13 as the plain digits. Invalid lengths and check digits are still rejected. Added cases to test_isbn_length.

@yezz123
yezz123 merged commit f36864e into pydantic:main Oct 12, 2026
11 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.

2 participants