【发布时间】:2020-12-27 15:34:50
【问题描述】:
我在 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'),
});
【问题讨论】:
标签: reactjs validation yup