summaryrefslogtreecommitdiff
path: root/users/app/models/email.rb
diff options
context:
space:
mode:
authorjessib <jessib@riseup.net>2013-09-23 12:23:08 -0700
committerjessib <jessib@riseup.net>2013-09-23 12:23:08 -0700
commita9c68ba0bbba7a95e9b4a3ff24554d1b0af6cbc5 (patch)
treec8a3bf7fe4c8001718ea31e56d036b267ee362e6 /users/app/models/email.rb
parent906e177b35606835c4f10a9de65d9bd83cbe21ad (diff)
This ensures that email addresses contain only lowercase letters, and that an identity's destination is a valid Email.
Diffstat (limited to 'users/app/models/email.rb')
-rw-r--r--users/app/models/email.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/users/app/models/email.rb b/users/app/models/email.rb
index 89c31bb..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