-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from ChalkSchools/constant
Fixing constant to disallow period at beginning or end
- Loading branch information
Showing
2 changed files
with
17 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
module EmailRepair | ||
class Constants | ||
def self.email_regex | ||
local_part_regex = "[#{email_local_part_valid_chars}]+" | ||
/#{local_part_regex}@(?:[a-z0-9\-]+\.)+(?:museum|travel|[a-z]{2,4})/ | ||
end | ||
class << self | ||
def email_regex | ||
local_part_regex = "[#{valid_chars}]" \ | ||
"([#{valid_chars_with_dot}]*[#{valid_chars}])?" | ||
/#{local_part_regex}@(?:[a-z0-9\-]+\.)+(?:museum|travel|[a-z]{2,4})/ | ||
end | ||
|
||
private | ||
|
||
def valid_chars_with_dot | ||
"#{valid_chars}\." | ||
end | ||
|
||
def self.email_local_part_valid_chars | ||
'a-z0-9_\.%\+\-\'' | ||
def valid_chars | ||
'a-z0-9_%\+\-\'' | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters