Sha256: 2ebf4b601e49bfdadbab16b6d768c6715cdf5c20be6b22bcde177a931dad0bec

Contents?: true

Size: 398 Bytes

Versions: 10

Compression:

Stored size: 398 Bytes

Contents

# frozen_string_literal: true

module Openapi3Parser
  module Validators
    class Url
      def self.call(input)
        message = %("#{input}" is not a valid URL)
        uri = URI.parse(input)

        message if !uri.relative? &&
                   !uri.is_a?(URI::HTTP) &&
                   !uri.is_a?(URI::HTTPS)
      rescue URI::InvalidURIError
        message
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
openapi3_parser-0.8.2 lib/openapi3_parser/validators/url.rb
openapi3_parser-0.8.1 lib/openapi3_parser/validators/url.rb
openapi3_parser-0.8.0 lib/openapi3_parser/validators/url.rb
openapi3_parser-0.7.0 lib/openapi3_parser/validators/url.rb
openapi3_parser-0.6.1 lib/openapi3_parser/validators/url.rb
openapi3_parser-0.6.0 lib/openapi3_parser/validators/url.rb
openapi3_parser-0.5.2 lib/openapi3_parser/validators/url.rb
openapi3_parser-0.5.1 lib/openapi3_parser/validators/url.rb
openapi3_parser-0.5.0 lib/openapi3_parser/validators/url.rb
openapi3_parser-0.4.0 lib/openapi3_parser/validators/url.rb