Sha256: b1ddcc84da7879a03ff3efd5e9d44ea6ca06cfe020e51ead8e5cafbb0bcdbb08

Contents?: true

Size: 367 Bytes

Versions: 16

Compression:

Stored size: 367 Bytes

Contents

require 'mail'

class EmailValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, value)
    begin
      parsed = Mail::Address.new(value)
    rescue Mail::Field::ParseError => e
    end
    record.errors.add attribute, "is not valid" unless !parsed.nil? && parsed.address == value && parsed.local != value #cannot be a local address
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
fe-2.1.6.1 app/validators/email_validator.rb
fe-2.1.6 app/validators/email_validator.rb
fe-2.1.5 app/validators/email_validator.rb
fe-2.1.4 app/validators/email_validator.rb
fe-2.1.3 app/validators/email_validator.rb
fe-2.1.2 app/validators/email_validator.rb
fe-2.1.1 app/validators/email_validator.rb
fe-2.0.8 app/validators/email_validator.rb
fe-2.0.6 app/validators/email_validator.rb
fe-2.0.5 app/validators/email_validator.rb
fe-2.0.4 app/validators/email_validator.rb
fe-2.0.3 app/validators/email_validator.rb
fe-2.0.2 app/validators/email_validator.rb
fe-2.0.1 app/validators/email_validator.rb
fe-2.0.0 app/validators/email_validator.rb
fe-1.0.0 app/validators/email_validator.rb