diff --git a/webapp/.vscode/tasks.json b/webapp/.vscode/tasks.json new file mode 100644 index 0000000..994a1e4 --- /dev/null +++ b/webapp/.vscode/tasks.json @@ -0,0 +1,43 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "npm", + "script": "tsc", + "problemMatcher": [], + "label": "npm: tsc", + "detail": "tsc -w", + "presentation": { + "reveal": "always", + "panel": "new" + }, + "runOptions": { + "runOn": "folderOpen" + }, + "group": "test" + }, + { + "type": "npm", + "script": "storybook", + "problemMatcher": [], + "label": "npm: storybook", + "detail": "start-storybook -p 6006 -s public", + "group": "build" + }, + { + "type": "npm", + "script": "build", + "problemMatcher": [], + "label": "npm: build", + "detail": "react-scripts build", + "group": "build" + }, + { + "type": "npm", + "script": "start", + "problemMatcher": [], + "label": "npm: start", + "detail": "react-scripts start" + }, + ] +} \ No newline at end of file diff --git a/webapp/src/types/validators/common.ts b/webapp/src/types/validators/common.ts index 192235f..7270bdc 100644 --- a/webapp/src/types/validators/common.ts +++ b/webapp/src/types/validators/common.ts @@ -17,10 +17,24 @@ export const AutomationTimeString = st.refine(st.string(), 'TimeString', (v, c) for (let i = 0; i < bits.length; i++) { const b = bits[i]; const num = Number(b); - if (!Number.isInteger(num) || (num < 0) || (num > 23)) { + if (Number.isInteger(num)) { + let max = 23; + if (i > 0) { + max = 59; + } + if ((num < 0) || (num > max)) { + return { + "branch": c.branch, + "message": `Time string should contain only positive numbers between 0-${max} as specified in https://www.home-assistant.io/docs/automation/trigger/#time-string`, + "path": c.path.concat( + bits.slice(0, i) + ).concat([`<<${b}>>`]) + } + } + } else { return { "branch": c.branch, - "message": "Time string should contain only positive numbers between 0-23 as specified in https://www.home-assistant.io/docs/automation/trigger/#time-string", + "message": `Time string should contain only positive numbers as specified in https://www.home-assistant.io/docs/automation/trigger/#time-string`, "path": c.path.concat( bits.slice(0, i) ).concat([`<<${b}>>`])