mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
new linting, make sure code is type safe
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import Schema from 'async-validator';
|
||||
import type { AnalogSensor, DeviceValue, ScheduleItem, Settings } from './types';
|
||||
import type { InternalRuleItem } from 'async-validator';
|
||||
import { IP_OR_HOSTNAME_VALIDATOR } from 'validators/shared';
|
||||
|
||||
import type { AnalogSensor, DeviceValue, ScheduleItem, Settings } from './types';
|
||||
|
||||
export const GPIO_VALIDATOR = {
|
||||
validator(rule: InternalRuleItem, value: number, callback: (error?: string) => void) {
|
||||
if (
|
||||
@@ -239,7 +240,7 @@ export const deviceValueItemValidation = (dv: DeviceValue) =>
|
||||
v: [
|
||||
{ required: true, message: 'Value is required' },
|
||||
{
|
||||
validator(rule: InternalRuleItem, value: any, callback: (error?: string) => void) {
|
||||
validator(rule: InternalRuleItem, value: unknown, callback: (error?: string) => void) {
|
||||
if (typeof value === 'number' && dv.m && dv.x && (value < dv.m || value > dv.x)) {
|
||||
callback('Value out of range');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user