Sha256: cb3145593527d9595d170e5382c9d422eed8fa98fd2ead67d4c0b300cb8b3ebb
Contents?: true
Size: 362 Bytes
Versions: 5
Compression:
Stored size: 362 Bytes
Contents
class EmailFormatValidator < ActiveModel::EachValidator def validate_each(object, attribute, value) unless EmailFormatValidator::is_valid_email(value) object.errors[attribute] << (options[:message] || "is not a valid email address") end end def self.is_valid_email(value) value =~ /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i end end
Version data entries
5 entries across 5 versions & 1 rubygems