zod-prisma
zod-prisma copied to clipboard
Nullability and JSON fields
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.
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