Sha256: 43eda4bfa8edcc4360cf4a1e545921d89b8b0d3f115c5e0f75fd6e93ffd5eaa5
Contents?: true
Size: 722 Bytes
Versions: 3
Compression:
Stored size: 722 Bytes
Contents
require "json_matchers/parser" module JsonMatchers class Validator def initialize(document_store:, schema_path:) @document_store = document_store @schema_path = schema_path end def validate(payload) json_schema.validate!(payload.as_json, fail_fast: true) [] rescue JsonSchema::Error => error [error.message] end private attr_reader :document_store, :schema_path def json_schema @json_schema ||= build_json_schema_with_expanded_references end def build_json_schema_with_expanded_references json_schema = Parser.new(schema_path).parse json_schema.expand_references!(store: document_store) json_schema end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
json_matchers-0.11.1 | lib/json_matchers/validator.rb |
json_matchers-0.11.0 | lib/json_matchers/validator.rb |
json_matchers-0.10.0 | lib/json_matchers/validator.rb |