Open RuntimeRascal opened 5 months ago
Any update on this? I also need that functionality
@RuntimeRascal, @roman-chivo thanks for the request and sorry for the late response. :wink:
In your case you can use custom validators like
/// z.custom.use(z.coerce.number.min(1, { message: 'Number must be greater than zero'}))
someNum Int
this sould result in
someNum: z.coerce.number.min(1, { message: 'Number must be greater than zero'})
hope this helps.
Is your feature request related to a problem? Please describe. A way to
coerce
types such asInt
from a Prisma schema. I am very new to both Prisma and Zod (first time using either) and seams the way to use ahtml
input (which works with string) to represent a number type and db value type is tocoerce
it.Describe the solution you'd like Would expect to use the following in a Prisma schema.
Describe alternatives you've considered Very tedious to write
onChange
handlers to coerce things manually.Additional context Error message
[@zod generator error]: 'coerce' is not a valid validator type.