Class: Grape::Validations::PresenceValidator

Inherits:
Validator
  • Object
show all
Defined in:
lib/grape/validations/presence.rb

Instance Attribute Summary

Attributes inherited from Validator

#attrs

Instance Method Summary collapse

Methods inherited from Validator

inherited, #initialize, #validate!

Constructor Details

This class inherits a constructor from Grape::Validations::Validator

Instance Method Details

#validate_param!(attr_name, params) ⇒ Object



4
5
6
7
8
# File 'lib/grape/validations/presence.rb', line 4

def validate_param!(attr_name, params)
  unless params.has_key?(attr_name)
    raise Grape::Exceptions::ValidationError, :status => 400, :param => attr_name, :message => "missing parameter: #{attr_name}"
  end
end