Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing on nested attributes #2

Open
gavinbelson opened this issue Jul 5, 2018 · 3 comments
Open

Allowing on nested attributes #2

gavinbelson opened this issue Jul 5, 2018 · 3 comments

Comments

@gavinbelson
Copy link

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

@msimonborg
Copy link
Owner

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?

@gavinbelson
Copy link
Author

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

@msimonborg
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants