react-awesome-query-builder
react-awesome-query-builder copied to clipboard
Default value to fields in case not found
Is your feature request related to a problem? Please describe. Is there any feature where we can provide default value to the field in case field value is not available in data.
Suggested JSON feature: Logic : {"var":["z", 26]} Data: {"a":1,"b":2} result : 26
Here, since z is not there in data . it takes 26 as default value.
Have you tried defaultValue
?
Eg. in example in readme:
qty: {
defaultValue: 1,
label: 'Qty',
type: 'number',
fieldSettings: {
min: 0,
},
valueSources: ['value'],
preferWidgets: ['number'],
},
what defaultValue does, i guess, is that it initiates the field with that value. In my usecase, I want that when jsonrule is being evaluated in backend, if the field value is not there in the db/(data is null), it does not throw error, instead , it takes up the the value as per the suggestion in top comment and evaluates the rule.
I guess what do you want to do is to customize JsonLogic behaviour. Customize jsonLogic.apply
function on backend, right?
Yes yes