Sha256: b083862d462a85b0e93e80cef3e7ceb4eafed050aa08cfa85a99674851ad7ba1

Contents?: true

Size: 846 Bytes

Versions: 7

Compression:

Stored size: 846 Bytes

Contents

# frozen_string_literal: true

module Grape
  module Validations
    class MultipleParamsBase < Base
      def validate!(params)
        attributes = MultipleAttributesIterator.new(self, @scope, params)
        array_errors = []

        attributes.each do |resource_params|
          begin
            validate_params!(resource_params)
          rescue Grape::Exceptions::Validation => e
            array_errors << e
          end
        end

        raise Grape::Exceptions::ValidationArrayErrors, array_errors if array_errors.any?
      end

      private

      def keys_in_common(resource_params)
        return [] unless resource_params.is_a?(Hash)
        all_keys & resource_params.keys.map! { |attr| @scope.full_name(attr) }
      end

      def all_keys
        attrs.map { |attr| @scope.full_name(attr) }
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
grape-1.5.0 lib/grape/validations/validators/multiple_params_base.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/grape-1.4.0/lib/grape/validations/validators/multiple_params_base.rb
grape-1.4.0 lib/grape/validations/validators/multiple_params_base.rb
grape-1.3.3 lib/grape/validations/validators/multiple_params_base.rb
grape-1.3.2 lib/grape/validations/validators/multiple_params_base.rb
grape-1.3.1 lib/grape/validations/validators/multiple_params_base.rb
grape-1.3.0 lib/grape/validations/validators/multiple_params_base.rb