Refactoring Validation Logic Not working

So I’m trying to refactor the validation logic but as soon as I replace:

if (!req.body.customerId)
  return res.status(400).send("customerId not found.");

 if (!req.body.movieId) return res.status(400).send("movieId not found.");

with this:

const { error } = validateReturn(req.body);
if (error) return res.status(400).send(error.details[0].message);

Most of my return tests will fail.

Why is that?

Hi I had the same issue, in my case the error was Joi.objectId is not a function, and I could not work out why as up to this point in the course we have added joi-objectid package to the other Joi validators.

Currently to get past this point in the validateReturn function I have just used Joi.string() to be able to progress, hopefully someone might be able to help us in the future but this way you can atleast progress.

Hi @Mathew,

thanks, but I moved on and deployed my app anyways. However I’ll try your solution on a copy of my app soon.