-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Support nested attribute names for validation error messages #1933
Comments
If you put a project up that reproduces this I can try to help. |
Hi @dblock here's a project with steps to reproduce in the README: https://github.com/amrrbakry/grape-nested-params-validation 👍 |
@amrrbakry I tried it. Looked like a bug at first, but is more like a non-feature. Looking at https://github.com/ruby-grape/grape/blob/master/lib/grape/exceptions/base.rb#L73 is getting called with
This is pretty annoying and we should be supporting the syntax that you were trying to use above with nested attributes, and hopefully preserving backwards compatibility. Would you care to write some specs and maybe implement this? |
Thank you, @dblock. I'd be happy to help with this. I'll take a look and see what I can do 👍 |
Hey @dblock, I need some help/opinion for the ideal way to tackle this. it seems that ParamsScope class constructs the full name of the param as a string (e.g.
do you suggest a change to the |
Without digging how it's used I think |
Hello,
I'm trying to override a nested attribute's name that gets show in the validation message, but it doesn't seem possible for nested params
I want to override
registration[total_capacity]
attribute name:my params:
en.yml
expected error message if total capacity is not sent:
"Total capacity must be present"
actual error message:
"registration[total_capacity] must be present"
is this not possible or is there a problem with my code?
using grape 0.16.2, ruby 2.3.3, rails 4.2
thanks
The text was updated successfully, but these errors were encountered: