File tree Expand file tree Collapse file tree 3 files changed +12
-17
lines changed
Expand file tree Collapse file tree 3 files changed +12
-17
lines changed Original file line number Diff line number Diff line change 1111* [ #1976 ] ( https://github.com/ruby-grape/grape/pull/1976 ) : Ensure classes/modules listed for autoload really exist - [ @dnesteryuk ] ( https://github.com/dnesteryuk ) .
1212* [ #1971 ] ( https://github.com/ruby-grape/grape/pull/1971 ) : Fix BigDecimal coercion - [ @FlickStuart ] ( https://github.com/FlickStuart ) .
1313* [ #1968 ] ( https://github.com/ruby-grape/grape/pull/1968 ) : Fix args forwarding in Grape::Middleware::Stack#merge_with for ruby 2.7.0 - [ @dm1try ] ( https://github.com/dm1try ) .
14-
14+ * [ # 1988 ] ( https://github.com/ruby-grape/grape/pull/1988 ) : Refactored the full_messages method and stop overriding full_message - [ @ hosseintoussi ] ( https://github.com/hosseintoussi ) .
1515### 1.3.0 (2020/01/11)
1616
1717#### Features
Original file line number Diff line number Diff line change @@ -57,10 +57,6 @@ def translate_attributes(keys, **options)
5757 end . join ( ', ' )
5858 end
5959
60- def translate_attribute ( key , **options )
61- translate ( "#{ BASE_ATTRIBUTES_KEY } .#{ key } " , default : key , **options )
62- end
63-
6460 def translate_message ( key , **options )
6561 case key
6662 when Symbol
Original file line number Diff line number Diff line change 55module Grape
66 module Exceptions
77 class ValidationErrors < Grape ::Exceptions ::Base
8+ ERRORS_FORMAT_KEY = 'grape.errors.format'
9+ DEFAULT_ERRORS_FORMAT = '%{attributes} %{message}'
10+
811 include Enumerable
912
1013 attr_reader :errors
@@ -41,21 +44,17 @@ def to_json(**_opts)
4144 end
4245
4346 def full_messages
44- messages = map { |attributes , error | full_message ( attributes , error ) }
47+ messages = map do |attributes , error |
48+ I18n . t (
49+ ERRORS_FORMAT_KEY ,
50+ default : DEFAULT_ERRORS_FORMAT ,
51+ attributes : translate_attributes ( attributes ) ,
52+ message : error . message
53+ )
54+ end
4555 messages . uniq!
4656 messages
4757 end
48-
49- private
50-
51- def full_message ( attributes , error )
52- I18n . t (
53- 'grape.errors.format' ,
54- default : '%{attributes} %{message}' ,
55- attributes : attributes . count == 1 ? translate_attribute ( attributes . first ) : translate_attributes ( attributes ) ,
56- message : error . message
57- )
58- end
5958 end
6059 end
6160end
You can’t perform that action at this time.
0 commit comments