Sha256: 4cd9d566afb8ad6d773b3f84c0c46927261399d5f9ea83be48d75ddbd8dd8e7d
Contents?: true
Size: 437 Bytes
Versions: 43
Compression:
Stored size: 437 Bytes
Contents
# frozen_string_literal: true require 'json-schema' require 'json' module Twiglet class Validator attr_accessor :custom_error_handler def initialize(schema) @schema = JSON.parse(schema) @custom_error_handler = ->(e) { raise e } end def validate(message) JSON::Validator.validate!(@schema, message) rescue JSON::Schema::ValidationError => e custom_error_handler.call(e) end end end
Version data entries
43 entries across 43 versions & 1 rubygems