validate-email-0.1.6/0000755000175600017560000000000012736172334013010 5ustar abhiabhivalidate-email-0.1.6/lib/0000755000175600017560000000000012736172334013556 5ustar abhiabhivalidate-email-0.1.6/lib/locale/0000755000175600017560000000000012736172334015015 5ustar abhiabhivalidate-email-0.1.6/lib/locale/en.yml0000644000175600017560000000010612736172334016137 0ustar abhiabhien: errors: messages: email: is not a valid email address validate-email-0.1.6/lib/validate_email.rb0000644000175600017560000000154412736172334017047 0ustar abhiabhirequire 'active_support/i18n' I18n.load_path << File.dirname(__FILE__) + '/locale/en.yml' require 'active_model' require 'mail' module ActiveModel module Validations class EmailValidator < ActiveModel::EachValidator def initialize(options) options.reverse_merge!(:message => :email) super(options) end def validate_each(record, attribute, value) begin mail = Mail::Address.new(value) unless mail.address == value && mail.domain.split(".").length > 1 record.errors.add(attribute, options[:message]) end rescue record.errors.add(attribute, options[:message]) end end end module ClassMethods def validates_email(*attr_names) validates_with EmailValidator, _merge_attributes(attr_names) end end end end validate-email-0.1.6/init.rb0000644000175600017560000000003112736172334014272 0ustar abhiabhirequire 'validate_email' validate-email-0.1.6/validate_email.gemspec0000644000175600017560000000415012736172334017315 0ustar abhiabhi######################################################### # This file has been automatically generated by gem2tgz # ######################################################### # -*- encoding: utf-8 -*- # stub: validate_email 0.1.6 ruby lib Gem::Specification.new do |s| s.name = "validate_email" s.version = "0.1.6" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.require_paths = ["lib"] s.authors = ["Tanel Suurhans", "Tarmo Lehtpuu"] s.date = "2012-07-12" s.description = "Library for validating email addresses in Rails 3 models." s.email = ["tanel.suurhans@perfectline.ee", "tarmo.lehtpuu@perfectline.ee"] s.extra_rdoc_files = ["README.markdown"] s.files = ["README.markdown", "init.rb", "install.rb", "lib/locale/en.yml", "lib/validate_email.rb"] s.homepage = "http://github.com/perfectline/validates_email/tree/master" s.rubygems_version = "2.5.1" s.summary = "Library for validating email addresses in Rails 3 models." if s.respond_to? :specification_version then s.specification_version = 3 if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then s.add_development_dependency(%q, [">= 3.0.0"]) s.add_runtime_dependency(%q, [">= 3.0"]) s.add_development_dependency(%q, [">= 1.1.2"]) s.add_runtime_dependency(%q, [">= 2.2.5"]) s.add_development_dependency(%q, [">= 0"]) s.add_development_dependency(%q, [">= 0"]) else s.add_dependency(%q, [">= 3.0.0"]) s.add_dependency(%q, [">= 3.0"]) s.add_dependency(%q, [">= 1.1.2"]) s.add_dependency(%q, [">= 2.2.5"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) end else s.add_dependency(%q, [">= 3.0.0"]) s.add_dependency(%q, [">= 3.0"]) s.add_dependency(%q, [">= 1.1.2"]) s.add_dependency(%q, [">= 2.2.5"]) s.add_dependency(%q, [">= 0"]) s.add_dependency(%q, [">= 0"]) end end validate-email-0.1.6/README.markdown0000644000175600017560000000327312736172334015516 0ustar abhiabhi# ValidateEmail This gem adds the capability of validating email addresses to `ActiveModel`. The gem only supports Rails 3 (has dependencies in ActiveModel and ActiveSupport 3.0) ### Installation # add this to your Gemfile gem "validate_email" # and then run rake gems:install # or just run sudo gem install validate_email ### Usage #### With ActiveRecord class Pony < ActiveRecord::Base # standard validation validates :email_address, :email => true # with allow_nil validates :email_address, :email => {:allow_nil => true} # with allow_blank validates :email_address, :email => {:allow_blank => true} end #### With ActiveModel class Unicorn include ActiveModel::Validations attr_accessor :email_address # with legacy syntax (the syntax above works also) validates_email :email_address, :allow_blank => true end #### I18n The error message will be looked up according to the standard ActiveModel::Errors scheme. For the above Unicorn class this would be: * activemodel.errors.models.unicorn.attributes.email_address.email * activemodel.errors.models.unicorn.email * activemodel.errors.messages.email * errors.attributes.email_address.email * errors.messages.email A default errors.messages.email of `is not a valid email address` is provided. You can also pass the `:message => "my custom error"` option to your validation to define your own custom message. ## Authors **Tanel Suurhans** () **Tarmo Lehtpuu** () ## License Copyright 2010 by PerfectLine LLC () and is released under the MIT license. validate-email-0.1.6/install.rb0000644000175600017560000000010312736172334014775 0ustar abhiabhiputs IO.read(File.join(File.dirname(__FILE__), 'README.markdown'))