Sha256: 8174df55ab1c1f017577521535a919f014444ba40375bd09f1121eef3389e44c

Contents?: true

Size: 427 Bytes

Versions: 7

Compression:

Stored size: 427 Bytes

Contents

# frozen_string_literal: true

module Openapi3Parser
  module Validators
    class MediaType
      REGEX = %r{
        \A
        (\w+|\*) # word or asterisk
        / # separating slash
        ([-+.\w]+|\*) # word (with +, - & .) or asterisk
        \Z
      }x.freeze

      def self.call(input)
        message = %("#{input}" is not a valid media type)
        message unless REGEX.match(input)
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
openapi3_parser-0.9.2 lib/openapi3_parser/validators/media_type.rb
mountapi-0.11.1 vendor/bundle/ruby/2.7.0/gems/openapi3_parser-0.9.1/lib/openapi3_parser/validators/media_type.rb
openapi3_parser-0.9.1 lib/openapi3_parser/validators/media_type.rb
openapi3_parser-0.9.0 lib/openapi3_parser/validators/media_type.rb
openapi3_parser-0.8.2 lib/openapi3_parser/validators/media_type.rb
openapi3_parser-0.8.1 lib/openapi3_parser/validators/media_type.rb
openapi3_parser-0.8.0 lib/openapi3_parser/validators/media_type.rb