diff --git a/src/index.ts b/src/index.ts index b09c896..790c531 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ import clone from "just-clone"; -import type { ZodTypeAny, input } from "zod"; +import type { ZodTypeAny, input, output } from "zod"; -export function init(schema: T): input { +export function init(schema: T): output { const def = schema._def; switch (def.typeName) { case "ZodObject": { @@ -13,8 +13,16 @@ export function init(schema: T): input { } case "ZodRecord": return {}; - case "ZodString": + case "ZodString": { + if (def.checks) { + for (const check of def.checks) { + if (check.kind === "uuid") { + return crypto.randomUUID(); + } + } + } return ""; + } case "ZodNumber": for (const check of def.checks || []) { if (["min", "max"].includes(check.kind)) {