lib/grape/validations/validators/all_or_none.rb in grape-1.2.4 vs lib/grape/validations/validators/all_or_none.rb in grape-1.2.5

- old
+ new

@@ -1,20 +1,13 @@ +require 'grape/validations/validators/multiple_params_base' + 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 - raise 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).empty? && keys_in_common(resource_params).length < attrs.length } + def validate_params!(params) + keys = keys_in_common(params) + return if keys.empty? || keys.length == all_keys.length + raise Grape::Exceptions::Validation, params: all_keys, message: message(:all_or_none) end end end end