I have an issue to create Joi schema for this input
{
projects: ["*","ABC123","ABC456"]
}
With the input above, it should throw an error.
I did try to use Joi.alternatives() like this
const schema = Joi.object({
projects:
Joi.array()
.items(
Joi.alternatives(
Joi.string().equal('*'),
Joi.string().regex(new RegExp(/^ABC_([0-9]{3,3})$/))
)
)
})
but it appears to allow both ["*"] and ["ABC123","DEF456"] together. I wanted it to be either ["*"] or ["ABC123","DEF456"], else it will be an error.
How can I actually achieve it by using Joi?