Closed simonseddon closed 5 years ago
I used a filter to get around this. Originally I'd lost hope in a filter, but supplying value
with a default of false
made it possible. My filter is below and includes lots of negative checks, but I dare say you can get away with simply: value === false
. Returning an empty string removes the value entirely from the final returned JSON.
var x = Xray({
filters:({
allow_undefined: function(value=false){
if(
!value.length ||
value === null ||
value === undefined ||
value === false
){
return ''
}else{
return value
}
}
})
})
For brevity:
allow_undefined: function(value=false){
return (value) ? value : ''
}
Since this is solvable, I'm closing. Can reopen if someone is interested in tackling.
Could use either an error or better still a fallback value? I've tried adding an allow_undefined filter to check for undefined, null and false returns but it doesn't work so I expect the error happens a level too deep to intercept?