mirror of
https://github.com/itsnaveenk/bazar3.git
synced 2025-12-19 21:27:05 +00:00
28 lines
691 B
JavaScript
28 lines
691 B
JavaScript
const Joi = require('joi');
|
|
|
|
exports.validateTeam = (req, res, next) => {
|
|
const schema = Joi.object({
|
|
name: Joi.string().max(100).required()
|
|
});
|
|
|
|
const { error } = schema.validate(req.body);
|
|
if (error) {
|
|
return res.status(400).json({ error: error.details[0].message });
|
|
}
|
|
next();
|
|
};
|
|
|
|
exports.validateResult = (req, res, next) => {
|
|
const schema = Joi.object({
|
|
team: Joi.string().max(100).required(),
|
|
date: Joi.string().pattern(/^\d{4}-\d{2}-\d{2}$/).required(),
|
|
result: Joi.string().max(10).required()
|
|
});
|
|
|
|
const { error } = schema.validate(req.body);
|
|
if (error) {
|
|
return res.status(400).json({ error: error.details[0].message });
|
|
}
|
|
next();
|
|
};
|