Sha256: 23f8fbb2985e6c38867a8cb09e6e38afb1b948d134c330699fe2ea8d40a19778

Contents?: true

Size: 441 Bytes

Versions: 10

Compression:

Stored size: 441 Bytes

Contents

# frozen_string_literal: true

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.new(params: all_keys, message: message(:all_or_none))
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

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