chrishoermann / zod-prisma-types

Generator creates zod types for your prisma models with advanced validation
Other
578 stars 43 forks source link

[BUG] @zod.custom.omit([input]) generates TS errors #243

Open Darkbound opened 4 months ago

Darkbound commented 4 months ago

Describe the bug I am trying to do inline validation with rich comments and zod, most of it works fine, but the omitting yields TS errors

generator client {
  provider = "prisma-client-js"
}

generator zod {
  provider         = "zod-prisma-types"
  output           = "../schemas/"
  useMultipleFiles = true
}

datasource db {
  provider  = "postgresql"
  url       = env("POSTGRES_PRISMA_URL") // uses connection pooling
  directUrl = env("POSTGRES_URL_NON_POOLING") // uses a direct connection
}

model TimeEntry {
  /// @zod.custom.omit([input])
  id   String @id @default(cuid())
  name String
}

For example here, just by trying to omit the id field for the inputs, I get 30 TS errors.

It works, zod does omit the field, but I cant pass TS checks.

Screenshots image

Package versions (please complete the following information):

Additional context Add any other context about the problem here.