File size: 272 Bytes
b152fd5
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
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();
  };
}