Open roc opened 2 years ago
try adding an output_validators: boolean_validator
?
That worked! Why would I need to add this additional step instead of just adding a validator though? This really tripped me up, I completely missed them in the docs
internally all extra dataset fields are stored as strings. output_validators
is a validator that is run to convert the internal string representation of a field to something else. This is used to return things like lists of strings or nested objects.
The boolean case is pretty common, if you can think of a good way to add this to the docs the contribution would be very welcome!
Finally found the time to add a quick example. I hope #347 helps! I didn't know exactly where to put it in the readme, so it is where it is. Will gladly move/modify as seems appropriate. Thanks
My
ckan_dataset.yaml
How it looks in the CKAN form
How it gets stored in the API
WHY?
What's happening here? Is the boolean validator causing it to be set as a string "true" or "false"?
To get around this I've made a horrible hack to our select preset form and assigned it in the case where we have a ckan-scheming option that sets boolean values:
https://github.com/Marvell-Consulting/ckanext-scheming/commit/e7d050aa8abf82e2a3981ba927009eb22cb18c22#diff-eb6d8b864cdb6ac8796aa9745b925510d8f56c8d9b5b0ef29fa2a9965948b172
There must be a better way! What am I missing?!