Class: MrCommon::Pattern

Inherits:
Object
  • Object
show all
Defined in:
app/models/mr_common/pattern.rb

Overview

Common regex patterns

Class Method Summary collapse

Class Method Details

.emailObject

Matches valid email addresses. Ensures that the @ symbol is preceded by something resembling a username and followed by something resembling a domain name.



10
11
12
# File 'app/models/mr_common/pattern.rb', line 10

def email
  /\A\S+@\S+\.\S+\z/
end

.phone_numberObject

Matches most phone numbers a person could enter. Tests for at least 7 of the characters that can appear in a phone number.



16
17
18
# File 'app/models/mr_common/pattern.rb', line 16

def phone_number
  /[\d()\\x+\- ]{7,}/
end