Sha256: e1cbfa10f8bdd8086c20a913e2f036ad818c260044c7b19a9cf94a044c79a7e1
Contents?: true
Size: 480 Bytes
Versions: 41
Compression:
Stored size: 480 Bytes
Contents
require 'mail' class EmailValidator < ActiveModel::EachValidator def validate_each(record,attribute,value) begin m = Mail::Address.new(value) r = m.domain && m.address == value t = m.__send__(:tree) r &&= (t.domain.dot_atom_text.elements.size > 1) rescue Exception => e r = false end record.errors[attribute] << (options[:message] || I18n.t( :invalid, :scope => [:activerecord, :errors, :messages] ) ) unless r end end
Version data entries
41 entries across 41 versions & 1 rubygems