我在 reactjs 中使用 Yup 进行表单验证。我的表格有两个日期,startDate
和endDate
. 我已成功实施范围验证。但在我的场景中 startDate 必须大于 endDate (不应该等于)。但下面的架构只检查小于 endDate 的场景。因为它接受相同的日期。请帮忙。
我正在使用的架构是:
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'),
});