I have this patch request where I update certain information depending on object of a document. When I send request using Postman(form-data) I get validation error saying "_id" is required.
Here's how it looks in Postman,
The route looks similar to this,
router.patch("/update", async (req, res) => {
try{
await updateValidation(req.body);
// whatever stuff processed with the data
} catch (err) {
res.status(400).send({ message: err.details[0].message });
}
}
The validation function looks like this,
const updateValidation = (data) => {
const schema = Joi.object({
_id: Joi.string().required(),
// other whatever validation possible
});
return schema.validateAsync(data);
};
Am I missing something here? I think I do, please point it out.
question from:https://stackoverflow.com/questions/65650767/key-passed-but-validation-fails-in-postman