We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a00b2d8 commit 51e3022Copy full SHA for 51e3022
lib/grape/exceptions/validation.rb
@@ -4,10 +4,12 @@ module Grape
4
module Exceptions
5
class Validation < Grape::Exceptions::Base
6
attr_accessor :params
7
+ attr_accessor :message_key
8
9
def initialize(args = {})
10
fail 'Params are missing:' unless args.key? :params
11
@params = args[:params]
12
+ @message_key = args[:message_key]
13
args[:message] = translate_message(args[:message_key]) if args.key? :message_key
14
super
15
end
spec/grape/exceptions/validation_spec.rb
@@ -0,0 +1,7 @@
1
+require 'spec_helper'
2
+
3
+describe Grape::Exceptions::Validation do
+ it 'store message_key' do
+ expect(Grape::Exceptions::Validation.new(params: ['id'], message_key: 'presence').message_key).to eq('presence')
+ end
+end
0 commit comments