chrishoermann / zod-prisma-types

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

[BUG] nullable is reversed on json type #238

Closed ygreenb closed 1 month ago

ygreenb commented 5 months ago

Describe the bug In Prisma schema, I defined a field as a Json nullable type, but the generated result from Zod is not nullable.

Screenshots

column is not nullable in prisma schema, but the generated type is not nullable

schema.prisma

model User {
  name String?
  bio  Json?
}

then run prisma migrate dev

prisma/generated/zod/index.ts

export const UserSchema = z.object({
  name: z.string().nullable(),
  bio: JsonValueSchema,
})

column is nullable in prisma schema, but the generated type is nullable

schema.prisma

model User {
  name String
  bio  Json
}

then run prisma migrate dev

prisma/generated/zod/index.ts

export const UserSchema = z.object({
  name: z.string(),
  bio: JsonValueSchema.nullable(),
})

Package versions (please complete the following information):

Additional context Add any other context about the problem here.