allowable icon indicating copy to clipboard operation
allowable copied to clipboard

Allowing on nested attributes

Open gavinbelson opened this issue 6 years ago • 3 comments

Is there a way to only allow certain values of a nested parameter? For example {:event => {:sub_events => [only allow certain sub events?]}}

gavinbelson avatar Jul 05 '18 18:07 gavinbelson

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?

msimonborg avatar Dec 08 '18 02:12 msimonborg

I would say {} so that if the allowed values are not met the entire hash is not accepted.

gavinbelson avatar Dec 08 '18 02:12 gavinbelson

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'] })

msimonborg avatar Dec 08 '18 03:12 msimonborg