Sha256: 7a7ca9f59696de4cc95200a5f05c8492c0e433e8b8bc06fcf614cad9602172a6

Contents?: true

Size: 926 Bytes

Versions: 12

Compression:

Stored size: 926 Bytes

Contents

# frozen_string_literal: true

require 'easy/jsonapi/exceptions'

module JSONAPI
  # Used to validate the serialized response before returned to a client
  module Response
    # TODO: Add config_manager options for out bound serialization validation

    # @param headers [Hash] The hash of response headers.
    # @param body [Hash | String] The ruby hash mimicking jsonapi or
    #   a JSON document to check for compliance
    # @return [Nilclass] if no errors are found
    # @raise [InvalidDocument | InvalidHeader] depending on what errors were found
    def self.validate(headers, body)
      # TODO: Spec checks based on collections which can be refered from the location header
      #   returned by the server
      JSONAPI::Exceptions::HeadersExceptions.check_compliance(headers.transform_keys(&:to_s).transform_keys(&:upcase))
      JSONAPI::Exceptions::DocumentExceptions.check_compliance(body)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
easy-jsonapi-1.0.11 lib/easy/jsonapi/response.rb
easy-jsonapi-1.0.10 lib/easy/jsonapi/response.rb
easy-jsonapi-1.0.9 lib/easy/jsonapi/response.rb
easy-jsonapi-1.0.8 lib/easy/jsonapi/response.rb
easy-jsonapi-1.0.7 lib/easy/jsonapi/response.rb
easy-jsonapi-1.0.6 lib/easy/jsonapi/response.rb
easy-jsonapi-1.0.5 lib/easy/jsonapi/response.rb
easy-jsonapi-1.0.4 lib/easy/jsonapi/response.rb
easy-jsonapi-1.0.3 lib/easy/jsonapi/response.rb
easy-jsonapi-1.0.2 lib/easy/jsonapi/response.rb
easy-jsonapi-1.0.1 lib/easy/jsonapi/response.rb
easy-jsonapi-1.0.0 lib/easy/jsonapi/response.rb