zerobyte/app/server/utils/branded.ts
2026-02-21 10:53:16 +01:00

9 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);