Sha256: 56903670239f9acf0ad177e08f236bd22127e5d69e431a9c71a144557afe151e

Contents?: true

Size: 790 Bytes

Versions: 20

Compression:

Stored size: 790 Bytes

Contents

require 'whyvalidationssuckin96/skippable_validation'
require 'whyvalidationssuckin96/attribute_based_validation'

module WhyValidationsSuckIn96
  
  # Checks for the presence of a given attribute.
  #
  # @example Default usage
  #   setup_validations do
  #     validates_presence_of :name
  #   end
  class ValidatesPresence < Validation  
    include WhyValidationsSuckIn96::SkippableValidation
    include WhyValidationsSuckIn96::AttributeBasedValidation
    
    DefaultOptions = {:message => "is not present"}
    
    def validate
      super
      if attribute_value.blank?
        fail
      else
        pass
      end
    end

  end # Validation

  ValidationBuilder.register_macro :validates_presence_of, WhyValidationsSuckIn96::ValidatesPresence
end   # WhyValidationsSuckIn96

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
whyvalidationssuckin96-1.6.4 lib/whyvalidationssuckin96/macros/validates_presence.rb
whyvalidationssuckin96-1.6.3 lib/whyvalidationssuckin96/macros/validates_presence.rb
whyvalidationssuckin96-1.6.2 lib/whyvalidationssuckin96/macros/validates_presence.rb
whyvalidationssuckin96-1.6.1 lib/whyvalidationssuckin96/macros/validates_presence.rb
whyvalidationssuckin96-1.6.0 lib/whyvalidationssuckin96/macros/validates_presence.rb
whyvalidationssuckin96-1.5.5 lib/whyvalidationssuckin96/macros/validates_presence.rb
whyvalidationssuckin96-1.5.4 lib/whyvalidationssuckin96/macros/validates_presence.rb
whyvalidationssuckin96-1.5.3 lib/whyvalidationssuckin96/macros/validates_presence.rb
whyvalidationssuckin96-1.5.2 lib/whyvalidationssuckin96/macros/validates_presence.rb
whyvalidationssuckin96-1.5.1 lib/whyvalidationssuckin96/macros/validates_presence.rb
whyvalidationssuckin96-1.5.0 lib/whyvalidationssuckin96/macros/validates_presence.rb
whyvalidationssuckin96-1.4.0 lib/whyvalidationssuckin96/macros/validates_presence.rb
whyvalidationssuckin96-1.3.1 lib/whyvalidationssuckin96/macros/validates_presence.rb
whyvalidationssuckin96-1.3.0 lib/whyvalidationssuckin96/macros/validates_presence.rb
whyvalidationssuckin96-1.2.3 lib/whyvalidationssuckin96/macros/validates_presence.rb
whyvalidationssuckin96-1.2.2 lib/whyvalidationssuckin96/macros/validates_presence.rb
whyvalidationssuckin96-1.2.1 lib/whyvalidationssuckin96/macros/validates_presence.rb
whyvalidationssuckin96-1.2.0 lib/whyvalidationssuckin96/macros/validates_presence.rb
whyvalidationssuckin96-1.1.0 lib/whyvalidationssuckin96/macros/validates_presence.rb
whyvalidationssuckin96-1.0.0 lib/whyvalidationssuckin96/macros/validates_presence.rb