New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

prisma-to-zod

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prisma-to-zod

Generate Zod validation schema from a Prisma schema.

  • 0.2.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

prisma-to-zod

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.

Installation

(p)npm install -D prisma-to-zod

Usage

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.

Programmatically

import { prismaToZod } from "prisma-to-zod";
import fs from "fs";

const schema = fs.readFileSync("prisma/schema.prisma", { encoding: "utf8" });

console.log(prismaToZod(schema));

Goals

  • Parse and update generated schema file instead of overwriting
  • Make library into a real Prisma generator

Suggestions, improvements, PRs, are welcome at the github repo.

Keywords

FAQs

Package last updated on 06 Feb 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc