lib/grape/validations/validators/default.rb in grape-1.4.0 vs lib/grape/validations/validators/default.rb in grape-1.5.0
- old
+ new
@@ -1,11 +1,11 @@
# frozen_string_literal: true
module Grape
module Validations
class DefaultValidator < Base
- def initialize(attrs, options, required, scope, opts = {})
+ def initialize(attrs, options, required, scope, **opts)
@default = options
super
end
def validate_param!(attr_name, params)
@@ -19,12 +19,11 @@
end
def validate!(params)
attrs = SingleAttributeIterator.new(self, @scope, params)
attrs.each do |resource_params, attr_name|
- if resource_params.is_a?(Hash) && resource_params[attr_name].nil?
- validate_param!(attr_name, resource_params)
- end
+ next unless @scope.meets_dependency?(resource_params, params)
+ validate_param!(attr_name, resource_params) if resource_params.is_a?(Hash) && resource_params[attr_name].nil?
end
end
private