Loading ckanext/dcatdonl/validator/valuelist_validator.py +9 −8 Original line number Original line Diff line number Diff line Loading @@ -217,27 +217,28 @@ def adms_distributiestatus(values): return _check_value('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. Checks if a given value is present in the given valuelist. :param name: str, the name of the 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 :return: str, the original value if it passes validation """ """ valid_values = _read_file_as_json(name) valid_values = _read_file_as_json(name) if isinstance(value, list): if isinstance(values, list): for val in value: for val in values: if val not in valid_values: if val not in valid_values: raise tk.Invalid('value [' + val + '] is not a valid ' + name) raise tk.Invalid('value [' + val + '] is not a valid ' + name) return value return values if value not in valid_values: if isinstance(values, basestring): raise tk.Invalid('value [' + value + '] is not a valid ' + name) if values not in valid_values: raise tk.Invalid('value [' + values + '] is not a valid ' + name) return value return values @cached @cached Loading Loading
ckanext/dcatdonl/validator/valuelist_validator.py +9 −8 Original line number Original line Diff line number Diff line Loading @@ -217,27 +217,28 @@ def adms_distributiestatus(values): return _check_value('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. Checks if a given value is present in the given valuelist. :param name: str, the name of the 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 :return: str, the original value if it passes validation """ """ valid_values = _read_file_as_json(name) valid_values = _read_file_as_json(name) if isinstance(value, list): if isinstance(values, list): for val in value: for val in values: if val not in valid_values: if val not in valid_values: raise tk.Invalid('value [' + val + '] is not a valid ' + name) raise tk.Invalid('value [' + val + '] is not a valid ' + name) return value return values if value not in valid_values: if isinstance(values, basestring): raise tk.Invalid('value [' + value + '] is not a valid ' + name) if values not in valid_values: raise tk.Invalid('value [' + values + '] is not a valid ' + name) return value return values @cached @cached Loading