class EmailValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) unless value =~ /.+@\S+\.\S+/ record.errors[attribute] << (options[:message] || 'is not a valid email') end end end