Skip to content

Commit

Permalink
Add type check to validation job
Browse files Browse the repository at this point in the history
  • Loading branch information
notherealmarco committed Jun 14, 2024
1 parent 5b49781 commit 7650531
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scripts/validate_questions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down

0 comments on commit 7650531

Please sign in to comment.