allowable
allowable copied to clipboard
Allowing on nested attributes
Is there a way to only allow certain values of a nested parameter? For example {:event => {:sub_events => [only allow certain sub events?]}}
what would be the desired result of the following code?
hash = { event: { sub_events: ['only allow certain sub-events'] } }
hash.allow(event: { sub_events: ['something else'] })
is it { event: {} } or { event: nil } or {} or something else?
I would say {} so that if the allowed values are not met the entire hash is not accepted.
in that example the current code already does return {}. but what about the following?
hash = { event: { sub_events: ['only allow certain sub-events'] } }
hash.allow(event: { pre_events: ['only allow certain pre-events'] })