Sha256: 2b6736c0136df0d4c5263b541df8cf2178dd08e4896cf307a109bdff4a54b0fe
Contents?: true
Size: 563 Bytes
Versions: 6
Compression:
Stored size: 563 Bytes
Contents
module Grape module Validations require 'grape/validations/validators/multiple_params_base' class AtLeastOneOfValidator < MultipleParamsBase def validate!(params) super if scope_requires_params && no_exclusive_params_are_present fail Grape::Exceptions::Validation, params: all_keys, message_key: :at_least_one end params end private def no_exclusive_params_are_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