'How to validate multiple file extensions with joi?
Let's say i want the user to upload only one of two types of files (pdf and docx). i will validate the file using joi.
Can you confirm is this code correct or not?
const joi = require('@hapi/joi')
const validateFormData = data => {
const shema = joi.object({
cv: joi
.string()
.valid(['application/msword', 'application/pdf'])
.required()
})
return shema.validate(data, { abortEarly: false })
}
module.exports = {
validateFormData
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
