Loading ckanext/dcatdonl/validator/valuelist_validator.py +9 −8 Original line number Diff line number Diff line Loading @@ -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 Loading Loading
ckanext/dcatdonl/validator/valuelist_validator.py +9 −8 Original line number Diff line number Diff line Loading @@ -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 Loading