add ADD and put in a validator as cmd can't be empty

This commit is contained in:
Proddy
2023-02-25 18:11:37 +01:00
parent 50400459ee
commit 9bae82592f
2 changed files with 97 additions and 55 deletions

View File

@@ -1,6 +1,6 @@
import Schema, { InternalRuleItem } from 'async-validator';
import { IP_OR_HOSTNAME_VALIDATOR } from 'validators/shared';
import { Settings } from './types';
import { Settings, ScheduleItem } from './types';
export const GPIO_VALIDATOR = {
validator(rule: InternalRuleItem, value: number, callback: (error?: string) => void) {
@@ -84,3 +84,8 @@ export const createSettingsValidator = (settings: Settings) =>
shower_alert_coldshot: [{ type: 'number', min: 1, max: 10, message: 'Time must be between 1 and 10 seconds' }]
})
});
export const schedulerItemValidation = (si: ScheduleItem, creating: boolean) =>
new Schema({
cmd: [{ required: true, message: 'Command is required' }]
});