/** * The shape of an id this site hands out: a UUID, as the database generates * them. * * Checked before an id from a URL or a request body reaches a query, so a * path like `/api/groups/not-an-id` is a 404 and never a database error about * an invalid uuid. It was written out in eleven files; the day one of them * is loosened or tightened, the others must not disagree about what an id is. */ export const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; export function isUuid(value: unknown): value is string { return typeof value === "string" && UUID.test(value); }