Skip to content

Commit

Permalink
Merge pull request #448 from vrk-kpa/LIKA-612_old-business-ids-error
Browse files Browse the repository at this point in the history
LIKA-612: Interpret empty old_business_ids as an empty list
  • Loading branch information
bzar authored Apr 10, 2024
2 parents 83b88be + ecef9a7 commit 96f634b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions ckanext/ckanext-apicatalog/ckanext/apicatalog/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,7 @@ def get_validators(self):
'list_to_json_string': validators.list_to_json_string,
'json_string_to_list': validators.json_string_to_list,
'debug': validators.debug,
'empty_to_list': validators.empty_to_list,
}

# IFacets
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
"field_name": "old_business_ids",
"label": "Old business ids",
"form_snippet": null,
"validators": "ignore_not_sysadmin keep_old_value_if_missing list_to_json_string default_value()",
"validators": "ignore_not_sysadmin keep_old_value_if_missing empty_to_list list_to_json_string default_value()",
"output_validators": "json_string_to_list"
},
{
Expand Down
6 changes: 6 additions & 0 deletions ckanext/ckanext-apicatalog/ckanext/apicatalog/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,9 @@ def validator(key, data, errors, context):
'context': context}
log.debug(f'Debug validator: {pformat(fields)}')
return validator


def empty_to_list(value):
if value == '' or value is None:
return []
return value

0 comments on commit 96f634b

Please sign in to comment.