I am using the node Joi module to perform some checks, and I am having problems using the .or () method.
In their documentation, they define use as:
var schema = Joi.object().keys({
a: Joi.any(),
b: Joi.any()
}).or('a', 'b');
But I'm trying to validate an object, and I wanted to use .or () to check for properties nested in different properties, got it? Sort of:
var schema = Joi.object().keys({
body:{
device:{
smthelse: Joi.any(),
ua: Joi.string()
}
},
headers:{
'user-agent': Joi.string()
}).or('body.device.ua', 'headers.user-agent');
But I can’t make it work. Does anyone know if I missed something? Is this a way for user .or () for nested objects?
Thank!
source
share