Closed vgarmash closed 7 months ago
Hi @vgarmash , thanks for reporting this. I'll look into it and update back here soon.
Hi @vgarmash , thanks for reporting this. I'll look into it and update back here soon.
When @@validate
is used, a zod schema is generated and used to validate the input data. Currently the schema is too strict for DateTime
field and requires a Date
object. I've made a fix to allow compatible strings (via z.coerce.date
). It's included in the latest v1.10.0 release. Please help check if it's working for you. Thanks!
We use CRUD API generated by the Zenstack with RESTful handler. We have never used the Model-level validation in our schema and decided to enable couple rules in one model. Apparently, there is some problem in Zod configuration or serialization layer in version 1.9.0. Without model-level validation rules we are able to add new entry via REST API but once we add " @@validate" to the model it start throwing us error 403 with Zod validation message for fields with DateTime type.
schema.zmodel:
Request:
Response:
As soon as I remove "@@validation" from our model, everything works properly.
Environment: package.json tsconfig.json