Class: WhyValidationsSuckIn96::ValidatesPresence

Inherits:
WhyValidationsSuckIn96::Validation show all
Includes:
WhyValidationsSuckIn96::AttributeBasedValidation, WhyValidationsSuckIn96::SkippableValidation
Defined in:
lib/whyvalidationssuckin96/macros/validates_presence.rb

Overview

Checks for the presence of a given attribute.

Examples:

Default usage

  setup_validations do
    validates_presence_of :name
  end

Constant Summary

DefaultOptions =
{:message => "is not present"}

Constants inherited from WhyValidationsSuckIn96::Validation

DefaultOptions

Instance Method Summary

Methods included from WhyValidationsSuckIn96::AttributeBasedValidation

#attribute, #attribute_value, #initialize

Methods inherited from WhyValidationsSuckIn96::Validation

#failed?, #has_run?, #initialize, #message, new_subclass, #passed?, #validates?

Constructor Details

This class inherits a constructor from WhyValidationsSuckIn96::AttributeBasedValidation

Instance Method Details

- (Object) validate



18
19
20
21
22
23
24
25
# File 'lib/whyvalidationssuckin96/macros/validates_presence.rb', line 18

def validate
  super
  if attribute_value.blank?
    fail
  else
    pass
  end
end