Class: Treaty::Response::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/treaty/response/validator.rb

Overview

Validator for response data

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(version_factory:, response_data: {}) ⇒ Validator

Returns a new instance of Validator.



18
19
20
21
# File 'lib/treaty/response/validator.rb', line 18

def initialize(version_factory:, response_data: {})
  @version_factory = version_factory
  @response_data = response_data
end

Class Method Details

.validate!(version_factory:, response_data: {}) ⇒ Hash

Validates response data against the response definition

Parameters:

  • response_data (Hash) (defaults to: {})

    Response data to validate

  • version_factory (Versions::Factory)

    Version factory with response definition

Returns:

  • (Hash)

    Validated and transformed response data



13
14
15
# File 'lib/treaty/response/validator.rb', line 13

def validate!(version_factory:, response_data: {})
  new(version_factory:, response_data:).validate!
end

Instance Method Details

#validate!Object



23
24
25
# File 'lib/treaty/response/validator.rb', line 23

def validate!
  validate_response_attributes!
end