I would like to use Joi to validate an object or an array of objects.
I have tried doing this but it looks like it's checking for both an Array of entities and entity. I would like it to only check one or the other. entity is also a joi object.
Joi.alternatives().try(Joi.array().items(entity), entity)
For example, I want both of these bodies to be validated
[
{name: "joe"},
{name: "tim"},
{name: "bob"}
]
{name: "joe"}
What's the best way to do this?