I'm using Joi to validate some data from user.
I want to compare between two keys (type: array) in the payload and validate that one should be the subset of the other.
for example:
{
"colors":["green", "blue"],
"animals":["cat"],
"branches":[{
"colors":["green", "red"]
}]
}
In above example i want to make sure that first array (colors) is superset of second array inside key branches (colors).
this could be achive by following code in js, but i want to do it using Joi.
const result1 = req.body.branches.colors.every(val => req.body.colors.includes(val));
Any help?