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
this will be accepted as valid even though "bar" is not a valid property on TestSchema TestSchema.strict(...) is how I would handle this manually but unsure how/if the default validation behaviour would be modified. Or is the only way to handle this to parse the data again in the handler?
The text was updated successfully, but these errors were encountered:
Hi @G4brym , I gave this a go and it doesn't seem to be working. I'm not sure if it's something else I've missed but the option seems to have no effect
constrouter=OpenAPIRouter({raiseUnknownParameters: true,});constTestSchema=z.object({foo: z.string(),});classTestPostextendsOpenAPIRoute{staticschema={requestBody: TestSchema,};asynchandle(request: Request,env: any,context: any,data: Record<string,any>){// Create typed objectconstbody=TestSchema.parse(data.body);return{ok: true};}}router.post('/test',TestPost)// 404 for all misses.all('*',()=>error(404,'not found'));
Then sending the payload below still returns the ok response
Is there a way to make use of the zod
Schema.strict
in the automatic validation of a request body? Or override/disable the automatic validation?At the moment if I create a schema
And then send this payload to the route
this will be accepted as valid even though "bar" is not a valid property on
TestSchema
TestSchema.strict(...)
is how I would handle this manually but unsure how/if the default validation behaviour would be modified. Or is the only way to handle this to parse the data again in the handler?The text was updated successfully, but these errors were encountered: