Sha256: 848a0fdf518761551d03aac86e49405f883f3c7b3659c0c9305f186562d4ee9f

Contents?: true

Size: 442 Bytes

Versions: 1

Compression:

Stored size: 442 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

1 entries across 1 versions & 1 rubygems

Version Path
grape-1.6.0 lib/grape/validations/validators/all_or_none.rb