const Joi = require('joi');

const validate = require('./validate');

const schemaSentMessage = Joi.object({
	id: Joi.string().required(),
	message: Joi.string().min(1).max(1400).required(),
});

module.exports.sentMessage = (req, _res, next) => {
	return validate(schemaSentMessage, req.body, next);
};

module.exports.validateUploadFile = (req, res, next) => {
	if (!req.file)
		return res.status(400).json({
			status: 'error',
			code: 400,
			data: 'Bad request',
			message: 'File not found',
		});
	next();
};
