From 62f0ae42e054a4b73209814648649c68d0d279d7 Mon Sep 17 00:00:00 2001 From: pietervdvn Date: Sun, 18 Apr 2021 14:37:16 +0200 Subject: [PATCH] Add detection of invalid numbers in opening hours input element --- UI/OpeningHours/OpeningHours.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/UI/OpeningHours/OpeningHours.ts b/UI/OpeningHours/OpeningHours.ts index 733f516..5164e96 100644 --- a/UI/OpeningHours/OpeningHours.ts +++ b/UI/OpeningHours/OpeningHours.ts @@ -189,7 +189,11 @@ export class OH { if(spl.length != 2){ return null; } - return {hours: Number(spl[0].trim()), minutes: Number(spl[1].trim())}; + const hm = {hours: Number(spl[0].trim()), minutes: Number(spl[1].trim())}; + if(isNaN(hm.hours) || isNaN(hm.minutes) ){ + return null; + } + return hm; } public static parseHHMMRange(hhmmhhmm: string): {