Exception: JSONAPI::Exceptions::ValidationErrors
- Defined in:
- lib/jsonapi/exceptions.rb
Instance Attribute Summary collapse
-
#messages ⇒ Object
Returns the value of attribute messages.
Instance Method Summary collapse
- #errors ⇒ Object
- #format_key(key) ⇒ Object
-
#initialize(messages) ⇒ ValidationErrors
constructor
A new instance of ValidationErrors.
Constructor Details
#initialize(messages) ⇒ ValidationErrors
Returns a new instance of ValidationErrors.
284 285 286 287 |
# File 'lib/jsonapi/exceptions.rb', line 284 def initialize() @messages = @key_formatter = JSONAPI.configuration.key_formatter end |
Instance Attribute Details
#messages ⇒ Object
Returns the value of attribute messages.
283 284 285 |
# File 'lib/jsonapi/exceptions.rb', line 283 def @messages end |
Instance Method Details
#errors ⇒ Object
293 294 295 296 297 298 299 300 301 302 303 304 305 |
# File 'lib/jsonapi/exceptions.rb', line 293 def errors .inject([]) do |arr, element| arr.concat( element[1].map do || JSONAPI::Error.new(code: JSONAPI::VALIDATION_ERROR, status: :unprocessable_entity, title: "#{format_key(element[0])} - #{}", detail: , path: "/#{element[0]}") end ) end end |
#format_key(key) ⇒ Object
289 290 291 |
# File 'lib/jsonapi/exceptions.rb', line 289 def format_key(key) @key_formatter.format(key) end |