Sha256: ea8f060852710f7ec5d8088c9aaa531473811e698ab201e0f22bedf7549de430
Contents?: true
Size: 469 Bytes
Versions: 3
Compression:
Stored size: 469 Bytes
Contents
require 'mail' module ActiveModel module Validations class EmailValidator < 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.add(attribute) unless r end end end end
Version data entries
3 entries across 3 versions & 1 rubygems