zod-prisma icon indicating copy to clipboard operation
zod-prisma copied to clipboard

Nullability and JSON fields

Open CarterGrimmeisen opened this issue 3 years ago • 1 comments

According to Prisma's docs JSON fields cannot be directly set to null. Instead one can utilize Prisma.JsonNull or Prisma.DbNull in order to set the field to a JSON value of null or to NULL the db field respectively.

My current plan is to update the generated zod schemas to match this behavior but I am curious as to what others think about this.

CarterGrimmeisen avatar Jan 18 '22 22:01 CarterGrimmeisen

The only issue that I see with this approach is using these schemas to validate forms in the frontend. We could use null on the frontend and add a transform that converts it to Prisma.JsonNull or Prisma.DbNull

zomars avatar Jan 25 '22 15:01 zomars