File: at_least_one_of.rb

package info (click to toggle)
ruby-grape 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,032 kB
  • sloc: ruby: 24,329; makefile: 6
file content (14 lines) | stat: -rw-r--r-- 393 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# frozen_string_literal: true

require 'grape/validations/validators/multiple_params_base'

module Grape
  module Validations
    class AtLeastOneOfValidator < MultipleParamsBase
      def validate_params!(params)
        return unless keys_in_common(params).empty?
        raise Grape::Exceptions::Validation.new(params: all_keys, message: message(:at_least_one))
      end
    end
  end
end