Sha256: 04a6c00d945b9309f97b0a4e3a321393b7057160ada5362c47d7829ab46957eb
Contents?: true
Size: 455 Bytes
Versions: 5
Compression:
Stored size: 455 Bytes
Contents
module HoboFields module Types class EmailAddress < String COLUMN_TYPE = :string def validate I18n.t("errors.messages.invalid") unless valid? || blank? end def valid? self =~ /^\s*([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\s*$/i end def to_html(xmldoctype = true) self.sub('@', " at ").gsub('.', ' dot ') end HoboFields.register_type(:email_address, self) end end end
Version data entries
5 entries across 5 versions & 1 rubygems