class Grape::Validations::Validators::Base

def validate!(params)

Returns:
  • (void) -

Raises:
  • (Grape::Exceptions::Validation) - if validation failed

Parameters:
  • params (Hash) -- parameters to validate

Other tags:
    Note: - Override #validate if you need to access the entire request.
def validate!(params)
  attributes = SingleAttributeIterator.new(self, @scope, params)
  # we collect errors inside array because
  # there may be more than one error per field
  array_errors = []
  attributes.each do |val, attr_name, empty_val|
    next if !@scope.required? && empty_val
    next unless @scope.meets_dependency?(val, params)
    validate_param!(attr_name, val) if @required || (val.respond_to?(:key?) && val.key?(attr_name))
  rescue Grape::Exceptions::Validation => e
    array_errors << e
  end
  raise Grape::Exceptions::ValidationArrayErrors.new(array_errors) if array_errors.any?
end