Question
How to configure field validation so that a user cannot enter a number smaller than the value in another field on the page?
23:28 Oct 14, 2024
"PDS_UsrActualFuelRemaining_s06444m": { "modelConfig": { "path": "PDS.UsrActualFuelRemaining" }, "validators": { "MyNumberValidator": { "type": "usr.MonthNumberValidator", "params": { "minValue": "0", "message": "Допустимі значення від 0 до 500", "maxValue": "500" } } } },
If I specify a range, the validator works. But when I try to use <strong>var OldWorkHour = await request.$context.PDS_UsrWorkHours_sjx2srh;</strong>
, I get an error.
Could you please help me figure out why this happens and how to fix it?
"usr.MonthNumberValidator": { validator: function(config) { return function(control) { var controlValue = control.value !== undefined ? parseFloat(control.value) : null; var minValue = config.minValue !== undefined ? parseFloat(config.minValue) : Number.MIN_SAFE_INTEGER; var maxValue = config.maxValue !== undefined ? parseFloat(config.maxValue) : Number.MAX_SAFE_INTEGER; var OldWorkHour = await request.$context.PDS_UsrWorkHours_sjx2srh; var isValueValid = controlValue >= minValue && controlValue <= maxValue; if (!isValueValid) { return { "invalid": { message: config.message || "Введене значення не відповідає умовам" } }; } // Якщо все добре, повертаємо null (успішна валідація) return null; }; }, params: [ { name: "minValue" }, { name: "maxValue" }, { name: "message" } ], async: false },
Like
0 comments