mirror of
https://github.com/appinfosapienza/so-un-bot.git
synced 2025-03-13 05:19:11 +01:00
Add type check to validation job
This commit is contained in:
parent
5b49781fa6
commit
7650531641
1 changed files with 3 additions and 2 deletions
|
@ -22,11 +22,12 @@ for filename in os.listdir("data/questions"):
|
|||
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.")
|
||||
|
|
Loading…
Reference in a new issue