Sha256: 0a238ffb108a65f8f2965e45da2eeb3dfa70c5851c25b80cad3de9e5996b765c

Contents?: true

Size: 815 Bytes

Versions: 3

Compression:

Stored size: 815 Bytes

Contents

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

3 entries across 3 versions & 2 rubygems

Version Path
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/grape-1.2.5/lib/grape/validations/validators/multiple_params_base.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/grape-1.2.5/lib/grape/validations/validators/multiple_params_base.rb
grape-1.2.5 lib/grape/validations/validators/multiple_params_base.rb