Sha256: 778e578d2e6748d8c874d4fd45f6e0e478add09e4f0ae4fdec76829af7bfec1f

Contents?: true

Size: 610 Bytes

Versions: 6

Compression:

Stored size: 610 Bytes

Contents

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

module JSON
  class Schema
    class UriFormat < FormatAttribute
      def self.validate(current_schema, data, fragments, processor, validator, options = {})
        return unless data.is_a?(String)
        error_message = "The property '#{build_fragment(fragments)}' must be a valid URI"
        begin
          JSON::Util::URI.parse(data)
        rescue JSON::Schema::UriError
          validation_error(processor, error_message, fragments, current_schema, self, options[:record_errors])
        end
      end
    end
  end
end

Version data entries

6 entries across 5 versions & 3 rubygems

Version Path
json-schema-ouidou-2.9.1 lib/json-schema/attributes/formats/uri.rb
json-schema-ouidou-2.9.0 lib/json-schema/attributes/formats/uri.rb
json-schema-3.0.0 lib/json-schema/attributes/formats/uri.rb
mountapi-0.11.1 vendor/bundle/ruby/2.7.0/bundler/gems/json-schema-2253a5ee6679/lib/json-schema/attributes/formats/uri.rb
mountapi-0.11.1 vendor/json-schema/lib/json-schema/attributes/formats/uri.rb
json-schema-2.8.1 lib/json-schema/attributes/formats/uri.rb