这适用于所有情况,除了同一天,
Yup.date()
.required(“Start Date is required”)
.test(“startDate”, “Start Date can not be a passed Date”, function (date) {
const cutoff = new Date();
const selectedDate = date;
return selectedDate >= cutoff;
}),
与其使用new Date()
获取日期/时间现在,不如将其时间设置为今天开始:
const cutoff = new Date();
cutoff.setHours(0, 0, 0, 0);