ciscoheat/prisma-to-zod(新しいタブで開きます)
主要言語: TypeScript
Generate Zod validation schemas from a Prisma schema.
- star 数
- 6
- watcher 数
- 1
- fork 数
- 0
- issue 数
- 0
- 最終更新
- 2024/07/19
主要言語: TypeScript
Generate Zod validation schemas from a Prisma schema.
This project was experimental, zod-prisma-types does everything you need and more.
Simple generator of Zod validation schemas from Prisma schemas.
The generated file exports schemas according to the name of the Prisma models, with type guards for missing keys when the schema evolves.
(p)npm install -D prisma-to-zod
p2z prisma/schema.prisma [output.ts]
Will generate a typescript file, ready for additional validations. If no output file is specified, the schema will be written to stdout.
NOTE: This should currently be regarded as a one-step process, since any additional generation will overwrite your modifications. A future version will update the schema without overwriting.
import { prismaToZod } from "prisma-to-zod"; import fs from "fs"; const schema = fs.readFileSync("prisma/schema.prisma", { encoding: "utf8" }); console.log(prismaToZod(schema));
Suggestions, improvements, PRs, are welcome at the github repo.