ulid / javascript

Universally Unique Lexicographically Sortable Identifier
MIT License
3.04k stars 107 forks source link

is_ulid(x) #79

Closed basaran closed 3 years ago

basaran commented 3 years ago

Hello, is there a validation / checking method provided with the library? Thank you.

rawpixel-vincent commented 2 years ago

was looking for that, would you mind give the answer if you found it? basically want to check if a string match the ulid specs

rawpixel-vincent commented 2 years ago

is myString.replace(/[^a-z0-9]/gmi, '').length === 26 a correct way to detect ULID?

basaran commented 2 years ago

sorry nope, I suppose the reason there is no validation, because there is nothing to validate as long as the length is matching. There are some libraries on npm to extract time from the hash itself, but I think the reason people don't put much emphasis on these things is because it's not really required. From what I understand, the ulids are made to aid sorted db indexes mostly.