Created
April 4, 2013 13:52
-
-
Save coderhs/5310513 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'resolv' | |
class MxRecordValidator < ActiveModel::EachValidator | |
def validate_each(record, attribute, value) | |
mail_servers = Resolv::DNS.open.getresources(value.split('@')[1], Resolv::DNS::Resource::IN::MX) | |
if mail_servers.empty? then | |
record.errors[attribute] << "Does not have a MX record assosiated with mail id" | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment