Class: EasyTalk::ErrorFormatter::JsonPointer

Inherits:
Base
  • Object
show all
Defined in:
lib/easy_talk/error_formatter/json_pointer.rb

Overview

Formats validation errors using JSON Pointer (RFC 6901) paths.

Converts attribute paths to JSON Pointer format pointing to the property location in the JSON Schema.

Examples:

Output

[
  { "pointer" => "/properties/name", "message" => "can't be blank", "code" => "blank" },
  { "pointer" => "/properties/email/properties/address", "message" => "is invalid", "code" => "invalid_format" }
]

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from EasyTalk::ErrorFormatter::Base

Instance Method Details

#formatArray<Hash>

Format the errors as an array with JSON Pointer paths.

Returns:

  • (Array<Hash>)

    Array of error objects with pointer paths



20
21
22
23
24
# File 'lib/easy_talk/error_formatter/json_pointer.rb', line 20

def format
  error_entries.map do |entry|
    build_error_object(entry)
  end
end