lib/grape/validations/validators/base.rb in grape-1.4.0 vs lib/grape/validations/validators/base.rb in grape-1.5.0
- old
+ new
@@ -11,11 +11,11 @@
# @param attrs [Array] names of attributes to which the Validator applies
# @param options [Object] implementation-dependent Validator options
# @param required [Boolean] attribute(s) are required or optional
# @param scope [ParamsScope] parent scope for this Validator
# @param opts [Hash] additional validation options
- def initialize(attrs, options, required, scope, opts = {})
+ def initialize(attrs, options, required, scope, **opts)
@attrs = Array(attrs)
@option = options
@required = required
@scope = scope
@fail_fast = opts[:fail_fast] || false
@@ -45,12 +45,10 @@
attributes.each do |val, attr_name, empty_val|
next if !@scope.required? && empty_val
next unless @scope.meets_dependency?(val, params)
begin
- if @required || val.respond_to?(:key?) && val.key?(attr_name)
- validate_param!(attr_name, val)
- end
+ validate_param!(attr_name, val) if @required || val.respond_to?(:key?) && val.key?(attr_name)
rescue Grape::Exceptions::Validation => e
array_errors << e
end
end