Sha256: efff300517ee802e0edcfcca50fd1677bd38a767420452129e1a02ddc9831344

Contents?: true

Size: 585 Bytes

Versions: 1

Compression:

Stored size: 585 Bytes

Contents

module Fakeit
  module Validation
    class Validator
      def initialize(operation)
        @operation = operation
      end

      def validate(body: '', params: {}, headers: {})
        options = OpenAPIParser::SchemaValidator::Options.new(coerce_value: true)

        @operation.validate_request_body('application/json', JSON.parse(body)) unless body.empty?
        @operation.validate_path_params(options)
        @operation.validate_request_parameter(params, headers, options)
      rescue StandardError => e
        raise ValidationError, e.message
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fakeit-0.1.1 lib/fakeit/validation/validator.rb