Skip to content

Commit 77eee20

Browse files
committed
Improve validation
1 parent 4333b0f commit 77eee20

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/panels/lovelace/common/validate-condition.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,14 @@ function validateScreenCondition(condition: ScreenCondition) {
293293
}
294294

295295
function validateTimeCondition(condition: TimeCondition) {
296-
return (
297-
(condition.after != null || condition.before != null) &&
298-
condition.weekdays?.every((w: WeekdayShort) => WEEKDAYS_SHORT.includes(w))
299-
);
296+
const hasTime = condition.after != null || condition.before != null;
297+
const hasWeekdays =
298+
condition.weekdays != null && condition.weekdays.length > 0;
299+
const weekdaysValid =
300+
!hasWeekdays ||
301+
condition.weekdays!.every((w: WeekdayShort) => WEEKDAYS_SHORT.includes(w));
302+
303+
return (hasTime || hasWeekdays) && weekdaysValid;
300304
}
301305

302306
function validateUserCondition(condition: UserCondition) {

0 commit comments

Comments
 (0)