UNPKG

@prismicio/types-internal

Version:
20 lines (15 loc) 415 B
import * as t from "io-ts" import { validate as validateUUID } from "uuid" import { withCustomError } from "../validators/function" export interface UUIDBrand { readonly UUID: unique symbol } export const UUID = withCustomError( t.brand( t.string, (s): s is t.Branded<string, UUIDBrand> => validateUUID(s), "UUID", ), () => "The value must be a valid UUID", ) export type UUID = t.TypeOf<typeof UUID>