Is there a way to validate if a string is nanoid?
andreluizsgf opened this issue · comments
André Luiz commented
Hi, i want to use nanoid to generate some random ids but would like to check if a given string is nanoid and then query for it in a database. is this validation possible?
Andrey Sitnik commented
I think /[\w_-]{21}/.test(id)
should work
Vinit Gupta commented
I was also looking for a validator. Is there a method added for this or does the above Regex work properly? @ai
Andrey Sitnik commented
Yes, it should works.