Added validation to picture uploads

This commit is contained in:
Daniel Cojocea
2024-07-02 14:51:31 -04:00
parent 9fef75e824
commit 92c7816623
6 changed files with 222 additions and 121 deletions
+16
View File
@@ -150,7 +150,23 @@ const createMonitorValidation = joi.object({
}),
});
const imageValidation = joi.object({
type: joi.string().valid("image/jpeg", "image/png").messages({
"any.only": "Invalid file format.",
"string.empty": "File type required.",
}),
size: joi
.number()
.max(3 * 1024 * 1024)
.messages({
"number.base": "File size must be a number.",
"number.max": "File size must be less than 3 MB.",
"number.empty": "File size required.",
}),
});
export {
imageValidation,
createMonitorValidation,
registerValidation,
loginValidation,