Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return error message if isbn validation failed #9

Open
dwightkelly opened this issue Apr 1, 2022 · 3 comments
Open

Return error message if isbn validation failed #9

dwightkelly opened this issue Apr 1, 2022 · 3 comments

Comments

@dwightkelly
Copy link

It would be useful to return an error message with details of why isbn validation failed.

@maxlath
Copy link
Member

maxlath commented Jun 1, 2022

That could be nice, but would definitely be a breaking change, unless that behavior is activated by a flag.

@Roman991
Copy link

Roman991 commented Jan 12, 2023

This could be an interesting feature.
Would u consider a PR with the following logic?

  1. IF input length = 10 AND it != starts with 978|979 AND parse = null >> ERROR
  2. ELSE IF input length = 13 AND it starts with 978|979 and parse = null >> ERROR
  3. ELSE IF input length > 13 >> ERROR
  4. ELSE >> null

so error is thrown only when there is formally ISBN-like input but after the parsing there is a null
883951856 (9 digits) >> null
97888 >> null
978883951856 >> null
9788839518569 >> valid
9788839518568 >> error

@maxlath
Copy link
Member

maxlath commented Sep 11, 2023

Maybe such a feature could be a new function, such as parseStrict, or behind a flag: parse(isbn, { strict: true }). In both case, that would remove the problem of the breaking change.

Another idea: it could also (optionally?) enrich the error with the info gathered by the audit function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants