You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem for me is that createdAt is rendered as nullable, where I want it to render as just string. Is there any workaround? I guess it contains null because z.coerce.date().parse(null) is valid, but not sure if it makes sense when it comes to openapi response schema.
Context: I use zod-prisma-types to generate zod schema from prisma schema, and it generates z.coerce.string() from a DateTime column as below:
// schema.prismamodelUser{createdAtDateTime}// the generated zod typeexportconstUser=z.object({createdAt: z.coerce.date(),})
And when I want to directly use the schema as response type, the createdAt field unexpectedly becomes nullable.
Thanks!
The text was updated successfully, but these errors were encountered:
Hi, I have a question about the conversion behavior of z.coerce.date.
With the below code:
we get the following output:
The problem for me is that
createdAt
is rendered as nullable, where I want it to render as juststring
. Is there any workaround? I guess it contains null becausez.coerce.date().parse(null)
is valid, but not sure if it makes sense when it comes to openapi response schema.Context: I use zod-prisma-types to generate zod schema from prisma schema, and it generates
z.coerce.string()
from a DateTime column as below:And when I want to directly use the schema as response type, the createdAt field unexpectedly becomes nullable.
Thanks!
The text was updated successfully, but these errors were encountered: