(schema: AnyZodObject)
| 3 | |
| 4 | const validate = |
| 5 | (schema: AnyZodObject) => |
| 6 | (req: Request, res: Response, next: NextFunction) => { |
| 7 | try { |
| 8 | schema.parse({ |
| 9 | body: req.body, |
| 10 | query: req.query, |
| 11 | params: req.params, |
| 12 | }); |
| 13 | next(); |
| 14 | } catch (e: any) { |
| 15 | return res.status(400).send(e.errors); |
| 16 | } |
| 17 | }; |
| 18 | |
| 19 | export default validate; |
nothing calls this directly
no outgoing calls
no test coverage detected