class JSON::Schema::CustomFormat

Public Class Methods

new(validation_proc) click to toggle source
# File lib/json-schema/attributes/formats/custom.rb, line 7
def initialize(validation_proc)
  @validation_proc = validation_proc
end

Public Instance Methods

validate(current_schema, data, fragments, processor, validator, options = {}) click to toggle source
# File lib/json-schema/attributes/formats/custom.rb, line 11
def validate(current_schema, data, fragments, processor, validator, options = {})
  begin
    @validation_proc.call data
  rescue JSON::Schema::CustomFormatError => e
    message = "The property '#{self.class.build_fragment(fragments)}' #{e.message}"
    self.class.validation_error(processor, message, fragments, current_schema, self, options[:record_errors])
  end
end