我正在尝试创建一些跨不同字段进行验证的验证规则。
我希望能够拥有规则“DateClosed 必须晚于 DateOpen”,但是当我使用我的自定义验证函数时,它只会传入 DateClosed 的数据。如何将 dateOpen 信息放入我的验证函数中?
数据源:
schema: {
model: {
id: "SomeId",
fields: {
SomeId: { editable: false, nullable: true },
Name: { editable: false, validation: { required: false } },
Description: { validation: { required: false } },
DateOpen: { type: "date", validation: { required: true } },
DateClosed: { type: "date", validation: { required: false, validationMessage: "Date Closed must be after Date Opened", custom: testValidation } },
}
}
}
验证功能:
function testValidation(element) {
if (element[0] !== null) {
if (element[0].name === "DateClosed") {
//Date logic here
return false;
}
else
return true;
}
}