Sha256: 044afc93ebef909c40a0c6debd1adf862c54df9f983500bceed991c02426c388
Contents?: true
Size: 544 Bytes
Versions: 33
Compression:
Stored size: 544 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 ').html_safe end HoboFields.register_type(:email_address, self) end end end
Version data entries
33 entries across 33 versions & 1 rubygems