Class: HoboFields::Types::EmailAddress
- Inherits:
-
String
- Object
- String
- HoboFields::Types::EmailAddress
- Defined in:
- lib/hobo_fields/types/email_address.rb
Constant Summary collapse
- COLUMN_TYPE =
:string
Instance Method Summary collapse
Instance Method Details
#to_html(xmldoctype = true) ⇒ Object
17 18 19 |
# File 'lib/hobo_fields/types/email_address.rb', line 17 def to_html(xmldoctype = true) ERB::Util.html_escape(self).sub('@', " at ").gsub('.', ' dot ').html_safe end |
#valid? ⇒ Boolean
13 14 15 |
# File 'lib/hobo_fields/types/email_address.rb', line 13 def valid? self =~ /^\s*([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\s*$/i end |
#validate ⇒ Object
9 10 11 |
# File 'lib/hobo_fields/types/email_address.rb', line 9 def validate I18n.t("errors.messages.invalid") unless valid? || blank? end |