File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -284,6 +284,11 @@ class ValidationErrors < Error
284284 attr_accessor :messages
285285 def initialize ( messages )
286286 @messages = messages
287+ @key_formatter = JSONAPI . configuration . key_formatter
288+ end
289+
290+ def format_key ( key )
291+ @key_formatter . format ( key )
287292 end
288293
289294 def errors
@@ -292,7 +297,7 @@ def errors
292297 element [ 1 ] . map do |message |
293298 JSONAPI ::Error . new ( code : JSONAPI ::VALIDATION_ERROR ,
294299 status : :unprocessable_entity ,
295- title : "#{ element [ 0 ] } - #{ message } " ,
300+ title : "#{ format_key ( element [ 0 ] ) } - #{ message } " ,
296301 detail : message ,
297302 path : "/#{ element [ 0 ] } " )
298303 end
Original file line number Diff line number Diff line change @@ -1684,7 +1684,7 @@ def test_create_validations_missing_attribute
16841684 assert_equal 2 , json_response [ 'errors' ] . size
16851685 assert_equal JSONAPI ::VALIDATION_ERROR , json_response [ 'errors' ] [ 0 ] [ 'code' ]
16861686 assert_equal JSONAPI ::VALIDATION_ERROR , json_response [ 'errors' ] [ 1 ] [ 'code' ]
1687- assert_match /date_joined - can't be blank/ , response . body
1687+ assert_match /dateJoined - can't be blank/ , response . body
16881688 assert_match /name - can't be blank/ , response . body
16891689 end
16901690
You can’t perform that action at this time.
0 commit comments