MCPcopy Create free account
hub / github.com/TomDoesTech/REST-API-Tutorial-Updated / validate

Function validate

src/middleware/validateResource.ts:5–17  ·  view source on GitHub ↗
(schema: AnyZodObject)

Source from the content-addressed store, hash-verified

3
4const 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
19export default validate;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected