Closed airrakeshkumarsharma closed 3 years ago
What else changes? Are you using the bundled version of Joi that celebrate exports or are you using one from package.json
?
What do you mean "not able to validate"? In what way?
Finally, you'll get better and faster responses if your issues are formatted correctly.
Yes, I am using the bundled version which comes with celebrate. And thanks for your comments.
Are you still having a problem or can this issue be closed?
This is very likely due to your joi upgrade, it was described as a breaking change in joi@16, see https://github.com/sideway/joi/issues/2037 section Array and object string coercion
. I'm not sure how celebrate handles joi extensions.
Have you tried setting convert: true
in the joi options? Also, you still haven't explained precisely HOW it is not able to validate. What error are you getting? What data are you passing? What does req.query
look like before you try to validate it. I can't really help because your responses do not include enough information.
Yes, I set the { convert: true }
but this also does not work.
Here is my input
filters=[{"key":"userType","value":"STUDENT"}, {"type":"hash","key":"email","value":"abhishek.k.v83408@gmail.com"}]
Output error ` details: Map(1) { 'query' => [Error [ValidationError]: "filters" must be an array] { _original: [Object], details: [Array] } },
} `
Log out req.query
in some middleware before calling celebrate
, let's see how the query string is actually being parsed.
node
version - 14.15.4celebrate
version - 13.0.4My
joi
schema looks like this:Here is an example value that is not working as expected:
?filters=[{"key":"userType","value":"STUDENT"}, {"type":"hash","key":"email","value":"abhishek.k.vghgghj@gmail.com"}]
The issue I am having with
celebrate
is:When I go to version 10 then celebrate is working fine and it is able to validate the params but when I just shift to v13 then it is not able to validate