You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

21 lines
597 B

import { z } from "zod";
export const uuidConfigSchema = z.object({
defaultVersion: z.enum(["v4", "v7"]).default("v4"),
defaultLength: z.number().int().positive().max(256).default(32),
});
export type UuidToolConfig = z.infer<typeof uuidConfigSchema>;
export const DEFAULT_UUID_CONFIG: UuidToolConfig = {
defaultVersion: "v4",
defaultLength: 32,
};
export function parseUuidConfig(raw: unknown): UuidToolConfig {
const parsed = uuidConfigSchema.safeParse(raw);
if (!parsed.success) {
throw new Error(`Invalid uuid config: ${parsed.error.message}`);
}
return parsed.data;
}