1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-12-20 23:41:20 +00:00

Fix validation

This commit is contained in:
Mo 2022-05-17 13:39:08 +02:00
parent d5dff6ccda
commit 57e81092fe

View file

@ -68,20 +68,24 @@ def validating_input(
ans = None ans = None
first_run = True 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: if not first_run:
done_validation = False
print("Invalid input!\n") print("Invalid input!\n")
else: else:
first_run = False first_run = False
ans = input(prompt) ans = input(prompt)
try: try:
formatted_ans = format_function(ans) ans = format_function(ans)
except Exception as ex: except Exception as ex:
ans = None continue
else:
done_validation = True
return formatted_ans return ans
def confirm(prompt): def confirm(prompt):