Updating KSA validator

This commit is contained in:
John Donaldson 2019-08-14 23:44:12 +01:00
parent 4e19e39872
commit acef542f66
1 changed files with 6 additions and 3 deletions

View File

@ -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):