Sha256: 93bc90f89f127edc72449aac2ce088b7f6cc12d410e1c52e937c4f3ae2588f3e

Contents?: true

Size: 423 Bytes

Versions: 17

Compression:

Stored size: 423 Bytes

Contents

module HoboFields

  class EmailAddress < String

    COLUMN_TYPE = :string

    def validate
      I18n.t("activerecord.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

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
hobofields-1.1.0 lib/hobo_fields/email_address.rb
hobofields-1.0.3 lib/hobo_fields/email_address.rb
hobofields-1.1.0.pre4 lib/hobo_fields/email_address.rb
hobofields-1.1.0.pre3 lib/hobo_fields/email_address.rb
hobofields-1.1.0.pre2 lib/hobo_fields/email_address.rb
hobofields-1.1.0.pre0 lib/hobo_fields/email_address.rb
hobofields-1.0.2 lib/hobo_fields/email_address.rb
hobofields-1.0.1 lib/hobo_fields/email_address.rb
hobofields-1.0.0 lib/hobo_fields/email_address.rb
hobofields-0.9.106 lib/hobo_fields/email_address.rb
hobofields-0.9.105 lib/hobo_fields/email_address.rb
hobofields-0.9.104 lib/hobo_fields/email_address.rb
hobofields-0.9.103 lib/hobo_fields/email_address.rb
hobofields-0.9.102 lib/hobo_fields/email_address.rb
hobofields-0.9.101 lib/hobo_fields/email_address.rb
hobofields-0.9.100 lib/hobo_fields/email_address.rb
hobofields-0.9.0 lib/hobo_fields/email_address.rb