Sha256: d34f4cf6a2e72f8e1959fd97a1d33121e39636178d6988ffe1b82d0c0224c0e2
Contents?: true
Size: 603 Bytes
Versions: 3
Compression:
Stored size: 603 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: message(: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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
grape-0.16.2 | lib/grape/validations/validators/all_or_none.rb |
grape-0.16.1 | lib/grape/validations/validators/all_or_none.rb |
grape-0.15.0 | lib/grape/validations/validators/all_or_none.rb |