Sha256: 769a4994f8c021499f9755d29c38f6115f25f817bf74fdf0bcd14500367faede

Contents?: true

Size: 1.17 KB

Versions: 23

Compression:

Stored size: 1.17 KB

Contents

module Authlogic
  # This is a module the contains regular expressions used throughout Authlogic. The point of extracting
  # them out into their own module is to make them easily available to you for other uses. Ex:
  #
  #   validates_format_of :my_email_field, :with => Authlogic::Regex.email
  module Regex
    # A general email regular expression. It allows top level domains (TLD) to be from 2 - 4 in length, any
    # TLD longer than that must be manually specified. The decisions behind this regular expression were made
    # by reading this website: http://www.regular-expressions.info/email.html, which is an excellent resource
    # for regular expressions.
    def self.email
      return @email_regex if @email_regex
      email_name_regex  = '[A-Z0-9_\.%\+\-]+'
      domain_head_regex = '(?:[A-Z0-9\-]+\.)+'
      domain_tld_regex  = '(?:[A-Z]{2,4}|museum|travel)'
      @email_regex = /^#{email_name_regex}@#{domain_head_regex}#{domain_tld_regex}$/i
    end
    
    # A simple regular expression that only allows for letters, numbers, spaces, and .-_@. Just a standard login / username
    # regular expression.
    def self.login
      /\A\w[\w\.+\-_@ ]+$/
    end
  end
end

Version data entries

23 entries across 23 versions & 14 rubygems

Version Path
authlogic-2.1.7 lib/authlogic/regex.rb
expertiza-authlogic-2.1.6.1 lib/authlogic/regex.rb
authlogic-rails3-2.2 lib/authlogic/regex.rb
kb-authlogic-2.1.7 lib/authlogic/regex.rb
wulffeld_authlogic-2.1.3 lib/authlogic/regex.rb
railsware-authlogic-2.1.6.1 lib/authlogic/regex.rb
cotweet-authlogic-2.1.6 lib/authlogic/regex.rb
jdl-authlogic-2.1.6.2 lib/authlogic/regex.rb
jdl-authlogic-2.1.6.1 lib/authlogic/regex.rb
authlogic-2.1.6 lib/authlogic/regex.rb
lockbox_middleware-1.2.1 vendor/gems/authlogic-2.1.3/lib/authlogic/regex.rb
authlogic-2.1.5 lib/authlogic/regex.rb
authlogic-2.1.4 lib/authlogic/regex.rb
namxam-authlogic-2.1.3.1 lib/authlogic/regex.rb
drogus-authlogic-2.1.3 lib/authlogic/regex.rb
novelys_authlogic-2.1.6 lib/novelys_authlogic/regex.rb
novelys_authlogic-2.1.5 lib/novelys_authlogic/regex.rb
novelys_authlogic-2.1.4 lib/novelys_authlogic/regex.rb
novelys_authlogic-2.1.3 lib/authlogic/regex.rb
skippy-authlogic-2.1.3 lib/authlogic/regex.rb