summaryrefslogtreecommitdiff
path: root/users/app/models/email.rb
diff options
context:
space:
mode:
Diffstat (limited to 'users/app/models/email.rb')
-rw-r--r--users/app/models/email.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/users/app/models/email.rb b/users/app/models/email.rb
index 1bcff1c..f38f2f5 100644
--- a/users/app/models/email.rb
+++ b/users/app/models/email.rb
@@ -3,10 +3,16 @@ class Email < String
validates :email,
:format => {
- :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/,
+ :with => /\A([^@\s]+)@((?:[-a-zA-Z0-9]+\.)+[a-zA-Z]{2,})\Z/, #checks format, but allows lowercase
:message => "needs to be a valid email address"
}
+ validates :email,
+ :format => {
+ :with => /\A[^A-Z]*\Z/, #forbids uppercase characters
+ :message => "letters must be lowercase"
+ }
+
def to_partial_path
"emails/email"
end
@@ -19,4 +25,8 @@ class Email < String
self
end
+ def handle
+ self.split('@').first
+ end
+
end