I have two inputs of type date (dateFrom and dateUntil) and I want to do the following validation: The difference between these two dates must be max 11 months(dateUntil - dateFrom <= 11 (months)).
I tried this:
validationSchema={() =>
Yup.lazy((values) => {
return Yup.object().shape({
importedDateUntil: Yup.date().Yup.ref('importedDateUntil').diff(Yup.ref('importedDateFrom'), "months") <= 11
});
})
}
But it's not working like this. Please let me know if you have any suggestions/solutions.