I'm using Yup for my form validations in reactjs. My form has two dates, startDate
and endDate
. I have successfully implemented range validation. but in my scenario startDate must be grater than endDate (should not be equal). but schema below only checks for less than scenario for endDate. where as it accept same dates. Please help.
schema I'm using is:
schema = Yup.object().shape({
startDate: Yup.date().min(new Date(), 'Please choose future date').typeError('Start Date is Required'),
endDate: Yup.date().min(Yup.ref('startDate'), 'End date must be grater than start date').typeError('End Date is Required'),
});