Sha256: 5a93b579e76b8e6b2196f0d769aba36a6a5d73616df1bdab295de76c86f7302a

Contents?: true

Size: 358 Bytes

Versions: 3

Compression:

Stored size: 358 Bytes

Contents

require 'grape/validations/validators/multiple_params_base'

module Grape
  module Validations
    class ExactlyOneOfValidator < MultipleParamsBase
      def validate_params!(params)
        return if keys_in_common(params).length == 1
        raise Grape::Exceptions::Validation, params: all_keys, message: message(:exactly_one)
      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/exactly_one_of.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/grape-1.2.5/lib/grape/validations/validators/exactly_one_of.rb
grape-1.2.5 lib/grape/validations/validators/exactly_one_of.rb