risen228 / nestjs-zod-prisma

Zod Prisma fork for nestjs-zod
MIT License
62 stars 11 forks source link

Use custom zod schema from imported zod schemas #17

Open MaximilianGaedig opened 12 months ago

MaximilianGaedig commented 12 months ago

How can I use a custom schema/type for validating a field?

Example:

// my custom schema
export const MyType = z.union([z.literal("a"),z.literal("b")])

// prisma schema
  type      String? /// @imports.MyType

// zod/entity.ts
import * as imports from "../zod-schemas"

// (added this manually to show what I would expect, instead there is a multi-line comment with the contents behind "///" above this following statement)
  type: imports.MyType, // imported from my custom schemas