File size: 353 Bytes
a1d9933
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
import { validationResult } from 'express-validator';
import { Request, Response, NextFunction } from 'express';


export const handleValidationErrors = (req: Request, res: Response, next: NextFunction) => {
  const errors = validationResult(req);
  if (!errors.isEmpty()) {
    return res.status(400).json({ errors: errors.array() });
  }
  next(); 
};