Closed objecttothis closed 1 month ago
Thanks for the kind words.
I don't have plans for graceful failures if validation fails. This code should do basic validation of the inputs and trough an exception if it is invalid.
What are you planning? An error message on the generated barcode? Or also exceptions but more explicit?
A common experience is for us, but I'm sure other users of the open source project I'm working on is where the Barcode type is selected in the settings, but an item does not have a valid barcode of that type. It sounds like me wrapping the call in a try catch block then acting appropriately based on exceptions thrown is the way to go, but here are some things I'm looking at trying to figure out:
In the end, I suppose it makes more sense for the exception to be thrown. Currently the thrown exception does state that x is not allowed or that the check digit failed. As I'm thinking through it, I think maybe my feature request would be for a type guessing function in the library or the ability to not pass the type and have it try to guess when the type is not passed. These are all things that I can implement in my code, but I thought I'd ask before doing it.
I'm replacing some deprecated Emberlabs code and php-barcode-generator has been fantastic. I think I'm going to need to do validation for the input barcode content as it doesn't seem to be built into this library. Is data validation and graceful failure something planned for this library?