summaryrefslogtreecommitdiff
path: root/users/app/models
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2012-12-10 20:16:26 +0100
committerAzul <azul@leap.se>2012-12-10 20:16:26 +0100
commitd9fa19106998bc6ac484494334dcf150bb6aa5d5 (patch)
tree3e0fee408c471f4355d0724387ad4787b2507999 /users/app/models
parent2695bf598cfbe860b202ebc96a4243af391d4582 (diff)
email format validations
Diffstat (limited to 'users/app/models')
-rw-r--r--users/app/models/email.rb5
-rw-r--r--users/app/models/user.rb7
2 files changed, 12 insertions, 0 deletions
diff --git a/users/app/models/email.rb b/users/app/models/email.rb
index 0988d9f..7c88c51 100644
--- a/users/app/models/email.rb
+++ b/users/app/models/email.rb
@@ -3,6 +3,11 @@ class Email
property :email, String
+ validates :email_forward,
+ :format => { :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/, :message => "needs to be a valid email address"}
+
+ timestamps!
+
def to_s
email
end
diff --git a/users/app/models/user.rb b/users/app/models/user.rb
index fcb211e..a41554d 100644
--- a/users/app/models/user.rb
+++ b/users/app/models/user.rb
@@ -26,6 +26,13 @@ class User < CouchRest::Model::Base
:confirmation => true,
:format => { :with => /.{8}.*/, :message => "needs to be at least 8 characters long" }
+ # TODO: write a proper email validator to be used in the different places
+ validates :email,
+ :format => { :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/, :message => "needs to be a valid email address"}
+
+ validates :email_forward,
+ :format => { :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/, :message => "needs to be a valid email address"}
+
timestamps!
design do