Sha256: 27774a88a72126872340d98fceb3937799584f0e0822d46273d9a6042b9d14a2
Contents?: true
Size: 534 Bytes
Versions: 24
Compression:
Stored size: 534 Bytes
Contents
require 'active_support/core_ext/string/output_safety' 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) ERB::Util.html_escape(self).sub('@', " at ").gsub('.', ' dot ') end HoboFields.register_type(:email_address, self) end end end
Version data entries
24 entries across 24 versions & 1 rubygems