Sha256: 8da80c1805d88ab890af303de304d77777d97e3186810e61836867547890dd73

Contents?: true

Size: 600 Bytes

Versions: 2

Compression:

Stored size: 600 Bytes

Contents

require 'json-schema/attribute'
require 'addressable/uri'
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
          Addressable::URI.parse(data)
        rescue Addressable::URI::InvalidURIError
          validation_error(processor, error_message, fragments, current_schema, self, options[:record_errors])
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
json-schema-2.5.2 lib/json-schema/attributes/formats/uri.rb
json-schema-2.5.1 lib/json-schema/attributes/formats/uri.rb