-
Hey there, Totally curious, like this library very much 🦊 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hey @S1SYPHOS , Thanks for the love 🙏🏻 You’re right that, unlike with the legacy public API, using the new one, you don’t need to validate a string before you try to convert it. So instead of: $isbn = new Isbn("9781234567890");
if ($isbn->isValid) {
$isbn13 = $isbn->format("ISBN-13");
} Now you can just do: $isbn13 = Isbn::convertToIsbn13("9781234567890"); and catch exceptions. But if you don’t need to convert a string and you only need to validate it, you can call: $isbn13 = Isbn::validateAsIsbn13("9781234567890 "); and catch exceptions. (I trust that you already understood all this, but I thought this might help other users that may be confused about the new API). The difference between those two methods is that While you're here, as you asked in a previous issue, you'll be happy to know that I plan to bring real exceptions to the library so you can distinguish between parsing (unrecoverable) and validation errors, with even specific exceptions so you can programmatically react depending on the reason why parsing or validation failed. |
Beta Was this translation helpful? Give feedback.
Hey @S1SYPHOS ,
Thanks for the love 🙏🏻
You’re right that, unlike with the legacy public API, using the new one, you don’t need to validate a string before you try to convert it. So instead of:
Now you can just do:
and catch exceptions.
But if you don’t need to convert a string and you only need to validate it, you can call:
and catch exceptions.
(I trust that you already understood all this, but I thought this might help other users that may be confused about the new API).
The difference betwe…