0.5.16 • Published 8 months ago

@tawasukha/zod-prisma v0.5.16

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Forked Version of Zod Prisma

Initially this generated was created by Carter Grimmeisen, but unfortunately only support for Prisma 3. I got tired of having update Zod Schema manually. This repo provides generating prisma schema model and keep the simplicity.

  • Support Prisma 4.*
  • For Internal Use Only

Built With

Getting Started

To get a local copy up and running follow these simple steps.

Installation

  1. Ensure your tsconfig.json enables the compiler's strict mode. Zod requires it and so do we, you will experience TS errors without strict mode enabled

  2. Add zod-prisma as a dev dependency

    pnpm add -D @fortezhuo/zod-prisma
  3. Add the zod-prisma generator to your schema.prisma

    generator zod {
      provider                 = "zod-prisma"
      output                   = "./zod" // (default) the directory where generated zod schemas will be saved
    
      relationModel            = true // (default) Create and export both plain and related models.
      // relationModel         = "default" // Do not export model without relations.
      // relationModel         = false // Do not generate related model
    
      modelCase                = "PascalCase" // (default) Output models using pascal case (ex. UserModel, PostModel)
      // modelCase             = "camelCase" // Output models using camel case (ex. userModel, postModel)
    
      modelSuffix              = "_model" // (default) Suffix to apply to your prisma models when naming Zod schemas
    
      imports                  = null // (default) will import the referenced file in generated schemas to be used via imports.someExportedVariable
    
      // https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-by-null-values
      prismaJsonNullability    = true // (default) uses prisma's scheme for JSON field nullability
      // prismaJsonNullability = false // allows null assignment to optional JSON fields
    }
  4. Run npx prisma generate or pnpm dlx prisma generate to generate your zod schemas

  5. Import the generated schemas form your selected output location

License

Distributed under the MIT License. See LICENSE for more information.

Special Thanks

Carter Grimmeisen for awesome Prisma Generator https://github.com/CarterGrimmeisen/zod-prisma

0.5.11

10 months ago

0.5.16

8 months ago

0.5.14

9 months ago

0.5.15

9 months ago

0.5.12

9 months ago

0.5.13

9 months ago

0.5.10

1 year ago

0.5.9

1 year ago