Sha256: d85fe15d48178ff8081c8679688eaf7b9316bd04e85a8d8b17d76164b7c56129

Contents?: true

Size: 687 Bytes

Versions: 15

Compression:

Stored size: 687 Bytes

Contents

require 'json-schema/attributes/format'
require 'json-schema/errors/custom_format_error'

module JSON
  class Schema
    class CustomFormat < FormatAttribute
      def initialize(validation_proc)
        @validation_proc = validation_proc
      end

      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
    end
  end
end

Version data entries

15 entries across 14 versions & 3 rubygems

Version Path
json-schema-5.1.0 lib/json-schema/attributes/formats/custom.rb
json-schema-ouidou-2.9.1 lib/json-schema/attributes/formats/custom.rb
json-schema-ouidou-2.9.0 lib/json-schema/attributes/formats/custom.rb
json-schema-5.0.1 lib/json-schema/attributes/formats/custom.rb
json-schema-5.0.0 lib/json-schema/attributes/formats/custom.rb
json-schema-4.3.1 lib/json-schema/attributes/formats/custom.rb
json-schema-4.3.0 lib/json-schema/attributes/formats/custom.rb
json-schema-4.2.0 lib/json-schema/attributes/formats/custom.rb
json-schema-4.1.1 lib/json-schema/attributes/formats/custom.rb
json-schema-4.1.0 lib/json-schema/attributes/formats/custom.rb
json-schema-4.0.0 lib/json-schema/attributes/formats/custom.rb
json-schema-3.0.0 lib/json-schema/attributes/formats/custom.rb
mountapi-0.11.1 vendor/bundle/ruby/2.7.0/bundler/gems/json-schema-2253a5ee6679/lib/json-schema/attributes/formats/custom.rb
mountapi-0.11.1 vendor/json-schema/lib/json-schema/attributes/formats/custom.rb
json-schema-2.8.1 lib/json-schema/attributes/formats/custom.rb