Class: JsonMatchers::Validator

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

Instance Method Summary collapse

Constructor Details

#initialize(document_store:, schema_path:) ⇒ Validator

Returns a new instance of Validator.



5
6
7
8
# File 'lib/json_matchers/validator.rb', line 5

def initialize(document_store:, schema_path:)
  @document_store = document_store
  @schema_path = schema_path
end

Instance Method Details

#validate(payload) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/json_matchers/validator.rb', line 10

def validate(payload)
  json_schema.validate!(payload.as_json, fail_fast: true)

  []
rescue JsonSchema::Error => error
  [error.message]
end