From 76505316415f03d8722d9090f7f255af65496ba9 Mon Sep 17 00:00:00 2001 From: Marco Realacci Date: Fri, 14 Jun 2024 14:47:12 +0200 Subject: [PATCH] Add type check to validation job --- scripts/validate_questions.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/validate_questions.py b/scripts/validate_questions.py index 907b8c1..bfa804c 100644 --- a/scripts/validate_questions.py +++ b/scripts/validate_questions.py @@ -22,11 +22,12 @@ raise Exception(str(data.index(q)) + ": Question has no answers.") for a in q["answers"]: - if a["text"] == "" and a["image"] == "": - raise Exception(str(data.index(q)) + ": Answer's text and image cannot both be empty.") if type(a["text"]) is not str or type(a["image"]) is not str: raise Exception(str(data.index(q)) + ": Some answer's parameters are null, missing or their type is wrong.") + if a["text"] == "" and a["image"] == "": + raise Exception(str(data.index(q)) + ": Answer's text and image cannot both be empty.") + except Exception as e: logging.error(getattr(e, 'message', repr(e))) logging.fatal(filename + " is invalid. Aborting.")