Sha256: 3b422ae3b3943c6f7e659972a895e0308f43250833003e648dfcf148ca08566f
Contents?: true
Size: 574 Bytes
Versions: 6
Compression:
Stored size: 574 Bytes
Contents
module Grape module Validations require 'grape/validations/validators/mutual_exclusion' class ExactlyOneOfValidator < MutualExclusionValidator def validate!(params) super if scope_requires_params && none_of_restricted_params_is_present fail Grape::Exceptions::Validation, params: all_keys, message_key: :exactly_one end params end private def none_of_restricted_params_is_present scoped_params.any? { |resource_params| keys_in_common(resource_params).empty? } end end end end
Version data entries
6 entries across 6 versions & 1 rubygems