paperclip/server/src/middleware/validate.ts

10 lines
272 B
TypeScript
Raw Normal View History

import type { Request, Response, NextFunction } from "express";
import type { ZodSchema } from "zod";
export function validate(schema: ZodSchema) {
return (req: Request, _res: Response, next: NextFunction) => {
req.body = schema.parse(req.body);
next();
};
}