Sha256: 38e95c0204595c6b58741b811367130949012d0d65a7e6e5108158184c5c2c6f

Contents?: true

Size: 393 Bytes

Versions: 1

Compression:

Stored size: 393 Bytes

Contents

# frozen_string_literal: true

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
grape-1.3.0 lib/grape/validations/validators/exactly_one_of.rb