From 6884482e789ed1a436de35eb4143ff30420211ab Mon Sep 17 00:00:00 2001 From: Verox001 Date: Fri, 19 Jan 2024 11:05:27 +0100 Subject: [PATCH] Fixed times and unit validation --- app.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app.py b/app.py index cc785bf..007f792 100644 --- a/app.py +++ b/app.py @@ -178,6 +178,14 @@ def habit_create(): except ValueError: errors['times'] = 'Die Anzahl muss eine Zahl sein.' + # Check that times is greater than 0 + if times <= 0: + errors['times'] = 'Die Anzahl muss größer als 0 sein.' + + # Check that unit is valid + if unit not in ['Tag', 'Woche', 'Monat', 'Jahr']: + errors['unit'] = 'Die Einheit ist ungültig.' + if errors: return render_template( 'habit.html',