const { validationResult } = require('express-validator');

const handleValidation = (req, res, next) => {
  const errors = validationResult(req);
  if (!errors.isEmpty()) {
    return res.status(400).json({
      status: 400,
      message: 'Error en la validación de datos',
      errors: errors.array()
    });
  }
  next();
};

module.exports = handleValidation;