'How to validate array of object inside array using Yup

Like in my case I want to validation a form which is inside array of array. below is the schema.

var model = {
template_name: "",
severityLevels: [
    severity_id: 0,
    level_name: "",
    alert_escalations: [
        {
            id: 0,
            template_id: 0,
            severity_id: 0,
            level_id: 0,
            duration_seconds: {
                days: 0,
                hrs: 0,
                mins: 0
            },
            notification_count: 0,
            reminder_interval_seconds: {
                days: 0,
                hrs: 0,
                mins: 0
            },
            is_email_enabled: true,
            is_sms_enabled: true
        }
    ]
]
}

I want to validate days inside duration_seconds object inside alert_escalations array inside severityLevels. How can I achieve this schema validation ? And what I had tried is:

  var schema = Yup.object().shape({
    template_name: Yup.string().required("Template name field is required."),
    severityLevels: Yup.array().of({
      alert_escalations: Yup.array().of({
        duration_seconds: Yup.object().shape({
          days: Yup.string().required("Day field is required"),
        }),
      }),
    }),
    
  });


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source