I am trying to create some validation rules that validate across different fields.
(我正在尝试创建一些验证规则,以在不同领域进行验证。)
I would like to be able to have the rule "DateClosed must be later than DateOpen", but when I use my custom validation function, it will only pass in the data for DateClosed.
(我希望规则“ DateClosed必须晚于DateOpen”,但是当我使用自定义验证功能时,它将仅传递DateClosed的数据。)
How can I get the dateOpen information into my validation function?(如何将dateOpen信息放入验证功能?)
Data Source:
(数据源:)
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 } },
}
}
}
Validation function:
(验证功能:)
function testValidation(element) {
if (element[0] !== null) {
if (element[0].name === "DateClosed") {
//Date logic here
return false;
}
else
return true;
}
}
ask by GodsCrimeScene translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…