Sha256: 0de27835ec74c93936beb3b640c47ab1ef76c9f67745a7a319b16a8eac2cfe8a
Contents?: true
Size: 599 Bytes
Versions: 5
Compression:
Stored size: 599 Bytes
Contents
module Grape module Validations require 'grape/validations/validators/multiple_params_base' class AllOrNoneOfValidator < MultipleParamsBase def validate!(params) super if scope_requires_params && only_subset_present fail Grape::Exceptions::Validation, params: all_keys, message_key: :all_or_none end params end private def only_subset_present scoped_params.any? { |resource_params| keys_in_common(resource_params).length > 0 && keys_in_common(resource_params).length < attrs.length } end end end end
Version data entries
5 entries across 5 versions & 1 rubygems