diff --git a/pykwalify/rule.py b/pykwalify/rule.py index 1856602..ec2e11e 100644 --- a/pykwalify/rule.py +++ b/pykwalify/rule.py @@ -1154,20 +1154,19 @@ def init_mapping_value(self, v, rule, path): if str(k).startswith("regex;") or str(k).startswith("re;"): log.debug(u"Found regex map rule") regex = k.split(";", 1) + if len(regex) != 2: raise RuleError( msg=u"Value: '{0}' for keyword regex is malformed".format(k), error_key=u"mapping.regex.malformed", path=path, ) - elif not regex[1].startswith('(') or not regex[1].endswith(')'): raise RuleError( msg=u"Regex '{0}' should start and end with parentheses".format(regex[1]), error_key=u"mapping.regex.missing_parentheses", path=path, ) - else: regex = regex[1] try: