chrishoermann / zod-prisma-types

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

fix(generator): Nullability of JSON field is reversed #240

Closed nordowl closed 1 month ago

nordowl commented 5 months ago

Fixes #238

Tested locally with a simple schema:

model User {
  id String @unique
  name String
  bio Json
}

model UserOptional {
  id String @unique
  name String?
  bio Json?
}

now correctly generates

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

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