Skip to content

Instantly share code, notes, and snippets.

@andywenk
andywenk / email_address_validator.rb
Created September 3, 2014 10:34
simple email adress validator; checks if the server responds and has an MX or A record
require 'mail'
require 'resolv'
require 'net/telnet'
class EmailAddressValidator < ActiveModel::EachValidator
attr_reader :mail
def validate_each(record, attribute, value)
return if options[:allow_nil] && value.nil?