Class: Validatable::ValidatesPresenceOf
- Inherits:
-
ValidationBase
- Object
- ValidationBase
- Validatable::ValidatesPresenceOf
- Defined in:
- lib/validations/validates_presence_of.rb
Overview
:nodoc:
Instance Attribute Summary
Attributes inherited from ValidationBase
Instance Method Summary collapse
Methods inherited from ValidationBase
after_validate, after_validations, all_after_validations, all_defaults, default, defaults, #initialize, option, #raise_error_if_key_is_dup, required_option, #run_after_validate, #should_validate?, #validate_this_time?
Methods included from Requireable
Methods included from Understandable
Constructor Details
This class inherits a constructor from Validatable::ValidationBase
Instance Method Details
#message(instance) ⇒ Object
8 9 10 |
# File 'lib/validations/validates_presence_of.rb', line 8 def (instance) super || "can't be empty" end |
#valid?(instance) ⇒ Boolean
3 4 5 6 |
# File 'lib/validations/validates_presence_of.rb', line 3 def valid?(instance) return false if instance.send(self.attribute).nil? instance.send(self.attribute).respond_to?(:strip) ? instance.send(self.attribute).strip.length != 0 : true end |