Validate response objects

Using the zod validator middleware it is possible to validate params , query, request body like:

const route = app.post(
  '/posts',
  zValidator(
    'form',
    z.object({
      body: z.string(),
    })
  ),
  (c) => {
    // ...
    return {
      ..
    }
  }
)


But is it also possible to validate the response object returned by the handler, to eg make sure response does contain required properties, but also does not include any unwanted properties?
Was this page helpful?