ai / nanoid

A tiny (124 bytes), secure, URL-friendly, unique string ID generator for JavaScript

Home Page:https://zelark.github.io/nano-id-cc/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a way to validate if a string is nanoid?

andreluizsgf opened this issue · comments

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?

I think /[\w_-]{21}/.test(id) should work

I was also looking for a validator. Is there a method added for this or does the above Regex work properly? @ai

Yes, it should works.