const { body, validationResult } = require("express-validator");

const matchValidator = {
    add: [
        body("leagueId").notEmpty().withMessage("leagueId  is required"),
        body("name1").notEmpty().withMessage("name1  is required"),
        body("name2").notEmpty().withMessage("name2  is required"),
        body("live").notEmpty().withMessage("live  is required"),
        body("start").notEmpty().withMessage("start  is required"),
        body("end").notEmpty().withMessage("end  is required"),
    ],
    error: (req, res, next) => {
        const error = validationResult(req);
        if (!error.isEmpty()) {
            return res.error(error.array().filter((err) => err.msg).map((err) => err.msg).join(', '));
        }
        next();
    }
}
module.exports = matchValidator;