Closed papidb closed 3 years ago
Trying taking a look at this test that uses the request context during validation. That might help you achieve what you're trying to do. I'm not 100% sure though since the .custom
method is a little limited with what all it's going to receive as arguments. Make sure you check out everything available in helpers
to see if there is anything useful there.
Thanks but looking into helpers helped a lot(got help from a friend).
helpers.state.ancestors[0] // gives the full object
node: v12.10.0
-celebrate: 12.1.0
-joi: 17.1.1
-My
joi
schema looks like this:Here is an example value that is not working as expected:
{phone: "08000000000", countryCode: "NGA" }
The issue I am having with
celebrate
is: I need access to the value of countryCode in req.body, and Joi.ref isn't doing any justiceI need the value of countryCode so I can use it to do custom validation of the phone number provided. Thanks