From 57e81092fe4f93065af88de59880f89767e6f227 Mon Sep 17 00:00:00 2001 From: Mo8it Date: Tue, 17 May 2022 13:39:08 +0200 Subject: [PATCH] Fix validation --- advlabdb/scripts/terminal_utils.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/advlabdb/scripts/terminal_utils.py b/advlabdb/scripts/terminal_utils.py index e497370..8c703a8 100644 --- a/advlabdb/scripts/terminal_utils.py +++ b/advlabdb/scripts/terminal_utils.py @@ -68,20 +68,24 @@ def validating_input( ans = None first_run = True + done_validation = False - while ans is None or not adj_check_constraints_function(ans): + while not done_validation or not adj_check_constraints_function(ans): if not first_run: + done_validation = False print("Invalid input!\n") else: first_run = False ans = input(prompt) try: - formatted_ans = format_function(ans) + ans = format_function(ans) except Exception as ex: - ans = None + continue + else: + done_validation = True - return formatted_ans + return ans def confirm(prompt):