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.
298 299 300 301 |
# File 'lib/jsonapi/exceptions.rb', line 298 def initialize() @messages = @key_formatter = JSONAPI.configuration.key_formatter end |
Instance Attribute Details
#messages ⇒ Object
Returns the value of attribute messages.
297 298 299 |
# File 'lib/jsonapi/exceptions.rb', line 297 def @messages end |
Instance Method Details
#errors ⇒ Object
307 308 309 310 311 312 313 314 315 316 317 318 319 |
# File 'lib/jsonapi/exceptions.rb', line 307 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
303 304 305 |
# File 'lib/jsonapi/exceptions.rb', line 303 def format_key(key) @key_formatter.format(key) end |