Sha256: c650b9f2b2f703b824ceb7d6944544c8629799163a22a8c461f932911236958c

Contents?: true

Size: 865 Bytes

Versions: 13

Compression:

Stored size: 865 Bytes

Contents

require 'whyvalidationssuckin96/skippable_validation'
require 'whyvalidationssuckin96/attribute_based_validation'
require 'whyvalidationssuckin96/vendor/rfc822'

module WhyValidationsSuckIn96
  
  # Checks whether a given attribute is a valid email address
  #
  # @example Default usage
  #   setup_validations do
  #     validates_as_email :email
  #   end
  #
  class ValidatesEmail < Validation  
    include WhyValidationsSuckIn96::SkippableValidation
    include WhyValidationsSuckIn96::AttributeBasedValidation
    
    DefaultOptions = {:message => "is not a valid email address"}
    
    def validate
      super
      WhyValidationsSuckIn96::RFC822::EmailAddress.match(attribute_value) ? pass : fail
    end

  end # Validation

  ValidationBuilder.register_macro :validates_as_email, WhyValidationsSuckIn96::ValidatesEmail
end   # WhyValidationsSuckIn96

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
whyvalidationssuckin96-1.6.4 lib/whyvalidationssuckin96/macros/validates_email.rb
whyvalidationssuckin96-1.6.3 lib/whyvalidationssuckin96/macros/validates_email.rb
whyvalidationssuckin96-1.6.2 lib/whyvalidationssuckin96/macros/validates_email.rb
whyvalidationssuckin96-1.6.1 lib/whyvalidationssuckin96/macros/validates_email.rb
whyvalidationssuckin96-1.6.0 lib/whyvalidationssuckin96/macros/validates_email.rb
whyvalidationssuckin96-1.5.5 lib/whyvalidationssuckin96/macros/validates_email.rb
whyvalidationssuckin96-1.5.4 lib/whyvalidationssuckin96/macros/validates_email.rb
whyvalidationssuckin96-1.5.3 lib/whyvalidationssuckin96/macros/validates_email.rb
whyvalidationssuckin96-1.5.2 lib/whyvalidationssuckin96/macros/validates_email.rb
whyvalidationssuckin96-1.5.1 lib/whyvalidationssuckin96/macros/validates_email.rb
whyvalidationssuckin96-1.5.0 lib/whyvalidationssuckin96/macros/validates_email.rb
whyvalidationssuckin96-1.4.0 lib/whyvalidationssuckin96/macros/validates_email.rb
whyvalidationssuckin96-1.3.1 lib/whyvalidationssuckin96/macros/validates_email.rb