how to use field value in viewModelConfigDiff as comparison value in the other field in viewModelConfigDiff too
12:26 Feb 11, 2025
Hi,
I want to make a validator that endDate cannot be erlier than leave startDate, in endDate field in viewModelConfigDiff,
Expectation:
My Code:
"PDS_UsrLeaveEndDate_quo1xia": { "modelConfig": { "path": "PDS.UsrLeaveEndDate" }, "validators": { "MySuperValidator2": { "type": "usr.FutureDateValidator2", "params": { "message": "#ResourceString(EndDateWarning)#", "startDate": "PDS_UsrLeaveStartDate_apq3vdm" } } } }
"usr.FutureDateValidator2": { validator: function (config) { return function (control) { let value = control.value; let startDate = config.startDate; let valueIsCorrect = value > startDate; var result; if (valueIsCorrect) { result = null; } else { console.log(startDate); console.log(value); result = { "usr.FutureDateValidator2": { message: config.message } }; } return result; }; }, params: [ { name: "message" }, { name: "startDate" } ], async: false },
But, value of startDate from the params is a String, how to get the actual value?
Thank you
Like
1 comments
12:11 Mar 03, 2025
Currently, you cannot pass the value of another field to a validator, this function is still under development. However, you can write something similar using global variables as described in this discussion.
Show all comments