From acef542f66c986c7b4f36f28765d42faf61e6b6d Mon Sep 17 00:00:00 2001 From: John Donaldson Date: Wed, 14 Aug 2019 23:44:12 +0100 Subject: [PATCH] Updating KSA validator --- devel/validate.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/devel/validate.py b/devel/validate.py index 150f0d3..e959b23 100644 --- a/devel/validate.py +++ b/devel/validate.py @@ -5,6 +5,7 @@ import logging import os import os.path +import re import moth @@ -132,14 +133,16 @@ class MothValidator: puzzle.body.seek(old_pos) - # Leaving this as a placeholder until KSAs are formally supported @staticmethod def check_ksa_format(puzzle): """Check if KSAs are properly formatted""" + + ksa_re = re.compile("^[KSA]\d{4}$") + if hasattr(puzzle, "ksa"): for ksa in puzzle.ksa: - if not ksa.startswith("K"): - raise MothValidationError("Unrecognized KSA format") + if ksa_re.match(ksa) is None: + raise MothValidationError("Unrecognized KSA format (%s)" % (ksa,)) def output_json(data):