ragalie/lisbn

Question about .valid? method

jbutton opened this issue · 3 comments

Hello.
I think the ".valid?" method is not accurate.
as I can see it's only checking simple regexp isbn.match(/^[0-9]{13}$/) and checksum

It doesn't work well for many ISBNs, for example 8830114722800 - it is mark as valid but it is not:

https://isbnsearch.org/search?s=8830114722800

For now I can use workaround:
if lisbn.parts.nil? && lisbn.parts(4).nil?
then it is invalid.

I would like to look around for proper ISBN validation rules, and use it in ".valid?" method. I will do the research.

I agree, I think the valid? method is poorly named right now. It really is more like valid_checksum?.

I'd be very happy to review a PR that uses the parts method to determine if the ISBN is really valid, and that renames the existing methods to valid_checksum?.

Thanks!

Yes the real validity test would be both checksum and that the range has been issued by ISBN international. Making the methods #valid_isbn_13? and #valid_isbn_10?public might be helpful.