Files
zerobyte/app/server/utils/branded.ts
Nico a0a813ed09 refactor: short id branded type (#552)
* refactor: short id branded type

* chore: pr feedbacks
2026-02-21 11:16:15 +01:00

10 lines
303 B
TypeScript

declare const brand: unique symbol;
export type Branded<T, B> = T & { [brand]: B };
export type ShortId = Branded<string, "ShortId">;
export const asShortId = (value: string): ShortId => value as ShortId;
export const isShortId = (value: string): value is ShortId => /^[A-Za-z0-9_-]+$/.test(value);