mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
improve dv validation, add back ugly step
This commit is contained in:
@@ -168,13 +168,11 @@ export const deviceValueItemValidation = (dv: DeviceValue) =>
|
||||
v: [
|
||||
{ required: true, message: 'Value is required' },
|
||||
{
|
||||
validator(rule: InternalRuleItem, value: string, callback: (error?: string) => void) {
|
||||
if (dv.u !== DeviceValueUOM.NONE && isNaN(+value)) {
|
||||
callback('Not a valid number');
|
||||
validator(rule: InternalRuleItem, value: any, callback: (error?: string) => void) {
|
||||
if (typeof value === 'number' && dv.m && dv.x && (value < dv.m || value > dv.x)) {
|
||||
callback('Value out of range');
|
||||
}
|
||||
(dv.m && Number(value) < dv.m) || (dv.x && Number(value) > dv.x)
|
||||
? callback('Value out of range')
|
||||
: callback();
|
||||
callback();
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user