Sha256: d8fe19dc8a787234cff9c8242ae72c1fe9949c03a72f771f88d07879ee6a804d

Contents?: true

Size: 406 Bytes

Versions: 3

Compression:

Stored size: 406 Bytes

Contents

require 'grape/validations/validators/multiple_params_base'

module Grape
  module Validations
    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, params: all_keys, message: message(:all_or_none)
      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/all_or_none.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/grape-1.2.5/lib/grape/validations/validators/all_or_none.rb
grape-1.2.5 lib/grape/validations/validators/all_or_none.rb