Set up a computed field with an appropriate validator
- Dominant language
- Python
- Stars
- 102
- Forks
- 182
- PR merge metrics
- No merged PRs in 30d
Description
Hi!
I am using CKAN 2.9 and I would like to have a field that is not set up by the user in the form, but computed separately and then displayed.
I started to set form_snippet to null, but by doing this, the field is always reset to null each time I try to modify the dataset.
I have been advised to use the [keep_old_value_if_missing](https://github.com/vrk-kpa/api-catalog/blob/1050ff51f04ebd061a3d73da130e662887076f7b/ckanext/ckanext-apicatalog_scheming/ckanext/apicatalog_scheming/validators.py#L99) validator. When a value for a given field on the form is missing (which is my case), the previously existing value is given.
This is a problem for me because, at the beginning, there is no previously existing value. The validator as it is now cannot work for me, unless I manage to give a random default value at the beginning.
How can I modify this validator so that it does what I want?
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the linked validators.py implementation of keep_old_value_if_missing and the CKAN 2.9 form handling for fields with form_snippet set to null. Reproduce dataset creation and editing with a computed field that has no initial value, then determine the expected validator behavior and add coverage for that case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100