Closed steida closed 4 years ago
@steida not sure what are you requesting?
I guess he's asking for a nanoid
branded type, as there is one for UUID
.
@DenisFrezzato looks like nanoid is a generation tool, not a validator, how is relevant to this library?
nanoid
is an ID generation tool, as UUID
is, so I'm guessing he's asking for a codec for nanoid
IDs, like there is one for UUID
.
NanoID branded type plus smart constructor example with recommended usage for beginners, maybe.
interface NanoIDBrand {
readonly NanoID: unique symbol;
}
export const NanoID = t.brand(
t.string,
(s): s is t.Branded<string, NanoIDBrand> => s.length <= 21, // regex would be better
'NanoID',
);
export type NanoID = t.TypeOf<typeof NanoID>;
import nanoid from 'nanoid';
import { NanoID } from '../types';
export const createNanoID = () => NanoID.decode(nanoid());
🚀 Feature request
I suppose nanoid is the state of art of client id generation.