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 11
11
* [ #1976 ] ( https://github.com/ruby-grape/grape/pull/1976 ) : Ensure classes/modules listed for autoload really exist - [ @dnesteryuk ] ( https://github.com/dnesteryuk ) .
12
12
* [ #1971 ] ( https://github.com/ruby-grape/grape/pull/1971 ) : Fix BigDecimal coercion - [ @FlickStuart ] ( https://github.com/FlickStuart ) .
13
13
* [ #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 ) .
15
15
### 1.3.0 (2020/01/11)
16
16
17
17
#### Features
Original file line number Diff line number Diff line change @@ -57,10 +57,6 @@ def translate_attributes(keys, **options)
57
57
end . join ( ', ' )
58
58
end
59
59
60
- def translate_attribute ( key , **options )
61
- translate ( "#{ BASE_ATTRIBUTES_KEY } .#{ key } " , default : key , **options )
62
- end
63
-
64
60
def translate_message ( key , **options )
65
61
case key
66
62
when Symbol
Original file line number Diff line number Diff line change 5
5
module Grape
6
6
module Exceptions
7
7
class ValidationErrors < Grape ::Exceptions ::Base
8
+ ERRORS_FORMAT_KEY = 'grape.errors.format'
9
+ DEFAULT_ERRORS_FORMAT = '%{attributes} %{message}'
10
+
8
11
include Enumerable
9
12
10
13
attr_reader :errors
@@ -41,21 +44,17 @@ def to_json(**_opts)
41
44
end
42
45
43
46
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
45
55
messages . uniq!
46
56
messages
47
57
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
59
58
end
60
59
end
61
60
end
You can’t perform that action at this time.
0 commit comments