Sha256: 568f63aa52e89a7113031feeed1aa275257c9390aa5356d2c43268673591d8cf

Contents?: true

Size: 602 Bytes

Versions: 5

Compression:

Stored size: 602 Bytes

Contents

require 'json-schema/attribute'
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

5 entries across 5 versions & 1 rubygems

Version Path
json-schema-2.8.0 lib/json-schema/attributes/formats/uri.rb
json-schema-2.7.0 lib/json-schema/attributes/formats/uri.rb
json-schema-2.6.2 lib/json-schema/attributes/formats/uri.rb
json-schema-2.6.1 lib/json-schema/attributes/formats/uri.rb
json-schema-2.6.0 lib/json-schema/attributes/formats/uri.rb