Closed brunoorosco closed 1 year ago
Thanks for the suggestion.
I'm assuming you mean something like this?
const isValid = (id) => sqids.encode(sqids.decode(id)) == id;
I've considered suggesting it as part of the spec as a convenience method, but it doesn't handle all use-cases well (for example if user adds minLength
param later on, their initially generated / shorter IDs would be considered invalid). That's why I wanted to give it some time and see how the library is used among projects, to see if people would appreciate this convenience method.
As an update, it is worth inserting a function that can validate the value being decoded. If this value is not created with the minLenght and Alphabet, it could return an empty value, or length == 0. This way we could receive n values , but only decode information that respects standards.