-
-
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
Custom Validation error messages #1295
Conversation
Thanks! Looking forward to code reviewing this - can you please rebase/squash it first? There're a lot of unrelated changes here to grok. |
2f24881
to
eb95f74
Compare
I have squashed it. There are still one or two unrelated changes which have penetrated while rebasing. Hope it helps to review the code. |
Well those two changes shouldn't be there :) This should fix it:
|
The change itself looks OK to me. It needs a README update and CHANGELOG. I am glad to see a very full test coverage too, wonder if there's a way to simplify the implementation a bit so that you don't have to copy paste the thing again and again. Like maybe enumerating something in the messages YML? |
Originally I had a similar idea in my mind. We can certainly enumerate messages from a YML file and extract the key based on the current route description. We can first check for the message in the
|
eb95f74
to
1d46522
Compare
I don't have any great suggestions wrt your question :) Please update README and CHANGELOG and this is good to go. |
1d46522
to
e722eab
Compare
Thanks! I am done with this. |
e722eab
to
55fe70e
Compare
Merged via e6a6c9c (I re-added a CHANGELOG line "Your contribution here"). Thanks! |
This bit me on a real life project, returning empty messages when a |
The spec for Custom Validators with an explicit |
Provides settings for custom validation error messages. Motivated by requests to build this feature on here Grape Custom Validation error message and here #621
If custom error message options are not provided error messages fall backs to defaults specified in
grape/locale/en.yml
. If you want i18n for your custom error messages passing locale symbol keys will translate the messages.presence, allow_blank, values, regexp
all_or_none_of
mutually_exclusive
exactly_one_of
at_least_one_of
Coerce