diff --git a/webapp/models.py b/webapp/models.py index f81f8f7..f60e026 100644 --- a/webapp/models.py +++ b/webapp/models.py @@ -119,18 +119,18 @@ class SignupForm(models.Model): } elif question_type == "radiobutton": options = q["options"] - pattern = "" - map(lambda x: pattern.join(f"^{x}$|"), options) + regexes = map(lambda x: f"^{x}$", options) + pattern = "|".join(regexes) properties[id] = { "type": "string", # Remove last regex or - "pattern": pattern[:-1], + "pattern": pattern, } elif question_type == "checkbox": options = q["options"] - pattern = "" - map(lambda x: pattern.join(f"^{x}$|"), options) + regexes = map(lambda x: f"^{x}$", options) + pattern = "|".join(regexes) properties[id] = { "type": "array", @@ -138,7 +138,7 @@ class SignupForm(models.Model): "maxItems": len(options), "items": { "type": "string", - "pattern": pattern[:-1] + "pattern": pattern } } else: raise Exception("invalid question type!")