import * as Yup from 'yup'

export const validators = (isQualification, isWorkExperience) => {
  if (isQualification){
    return Yup.object({

    
      Qualification: Yup.array().of(
        Yup.object().shape({
          Details: Yup.string()
                .required('Details is required'),
          CompletionYear: Yup.string()
                .required('CompletionYear is required')
        })
      ).min(1, 'Qualification is required'),
    })
  }
  else if (isWorkExperience){
    return Yup.object(
      {
        WorkExperience: Yup.array().of(
          Yup.object().shape({
            Details: Yup.string()
                  .required('Details is required'),
            FromDate: Yup.string()
                  .required('FromDate is required'),
            TillDate: Yup.string()
                  .required('Till-Date is required'),
          })
        ).min(1, 'Work experience is required'),
      }
    )

  }
  else{
    return Yup.object({
      Certification: Yup.array().of(
        Yup.object().shape({
          Details: Yup.string()
                .required('Details is required'),
          CompletionYear: Yup.string()
                .required('CompletionYear is required')
        })
      ).min(1, 'Certification is required')
    })
  }
}


