Joi validation for array elements

Hi Team,

Please help me to implement below validations using Joi:

My schema:-

const schema = Joi.object({
createdDate: Joi.string().required(),
futureDate: Joi.string().allow("").optional(),
Events: Joi.array().items({
status: Joi.string().required(),
type: Joi.string().required()

My input request will be like this. I am validating below request with above schema and validation should be if Events.type == “XYZ” then futureDate is required else optional.

“createdDate”: “2021-02-02T00:00:00”,
“futureDate”: “2021-02-02T00:00:00”,
“Events”: [
“status”: “P”,
“type”: “ABC”
“status”: “S”,
“type”: “XYZ”