Sha256: 972e60bdd753f10b1c597f370afffe487d6a864a4ed408a9b80f3a97d393898a

Contents?: true

Size: 425 Bytes

Versions: 10

Compression:

Stored size: 425 Bytes

Contents

# frozen_string_literal: true

module Grape
  module Validations
    module Validators
      class AllOrNoneOfValidator < MultipleParamsBase
        def validate_params!(params)
          keys = keys_in_common(params)
          return if keys.empty? || keys.length == all_keys.length

          raise Grape::Exceptions::Validation.new(params: all_keys, message: message(:all_or_none))
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
grape-2.2.0 lib/grape/validations/validators/all_or_none_of_validator.rb
grape-2.1.3 lib/grape/validations/validators/all_or_none_of_validator.rb
grape-2.1.2 lib/grape/validations/validators/all_or_none_of_validator.rb
grape-2.1.1 lib/grape/validations/validators/all_or_none_of_validator.rb
grape-2.1.0 lib/grape/validations/validators/all_or_none_of_validator.rb
grape-2.0.0 lib/grape/validations/validators/all_or_none_of_validator.rb
grape-1.8.0 lib/grape/validations/validators/all_or_none_of_validator.rb
grape-1.7.1 lib/grape/validations/validators/all_or_none_of_validator.rb
grape-1.7.0 lib/grape/validations/validators/all_or_none_of_validator.rb
grape-1.6.1 lib/grape/validations/validators/all_or_none_of_validator.rb