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

Version Path
hobo_fields-1.3.0.pre14 lib/hobo_fields/types/email_address.rb
hobo_fields-1.3.0.pre13 lib/hobo_fields/types/email_address.rb
hobo_fields-1.3.0.pre12 lib/hobo_fields/types/email_address.rb
hobo_fields-1.3.0.pre11 lib/hobo_fields/types/email_address.rb
hobo_fields-1.3.0.pre10 lib/hobo_fields/types/email_address.rb