Commit be5b2d7a authored by Willem ter Berg's avatar Willem ter Berg

valuelistvalidation oddness

parent 43d2aef8
......@@ -217,27 +217,28 @@ def adms_distributiestatus(values):
return _check_value('adms_distributiestatus', values)
def _check_value(name, value):
def _check_value(name, values):
"""
Checks if a given value is present in the given valuelist.
:param name: str, the name of the valuelist
:param value: str, the value to check
:param values: str, the value to check
:return: str, the original value if it passes validation
"""
valid_values = _read_file_as_json(name)
if isinstance(value, list):
for val in value:
if isinstance(values, list):
for val in values:
if val not in valid_values:
raise tk.Invalid('value [' + val + '] is not a valid ' + name)
return value
return values
if value not in valid_values:
raise tk.Invalid('value [' + value + '] is not a valid ' + name)
if isinstance(values, basestring):
if values not in valid_values:
raise tk.Invalid('value [' + values + '] is not a valid ' + name)
return value
return values
@cached
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment