Sha256: 4a3bcc827af87541054923e2860b2d9cb03b6a7ea51f235bdd241055ea65c1a6
Contents?: true
Size: 580 Bytes
Versions: 1
Compression:
Stored size: 580 Bytes
Contents
# frozen_string_literal: true require 'grape/validations/validators/multiple_params_base' module Grape module Validations module Validators class ExactlyOneOfValidator < MultipleParamsBase def validate_params!(params) keys = keys_in_common(params) return if keys.length == 1 raise Grape::Exceptions::Validation.new(params: all_keys, message: message(:exactly_one)) if keys.length.zero? raise Grape::Exceptions::Validation.new(params: keys, message: message(:mutual_exclusion)) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
grape-1.6.2 | lib/grape/validations/validators/exactly_one_of.rb |