added tasks + timestring validation
This commit is contained in:
1 parent
fb30d577aa
commit
041c2f02d5
2 files changed
+59
-2
No files matched your search
Vendored
+43
@@ -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"
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -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}>>`])
|
||||
|
||||
Reference in new issue
Block a user