Permalink
Browse files

More form validation tweaks.

  • Loading branch information...
1 parent b8da2ae commit 5e2e27fbbc19fd0955188c419ddf1f224ebdd0f8 francis committed Aug 27, 2009
Showing with 4 additions and 2 deletions.
  1. +4 −2 app/models/user.rb
View
@@ -23,7 +23,7 @@
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: user.rb,v 1.99 2009-08-27 15:41:54 francis Exp $
+# $Id: user.rb,v 1.100 2009-08-27 15:44:23 francis Exp $
require 'digest/sha1'
@@ -95,7 +95,9 @@ def visible_comments
end
def validate
- errors.add(:email, "doesn't look like a valid address") unless MySociety::Validate.is_valid_email(self.email)
+ if self.email != "" && !MySociety::Validate.is_valid_email(self.email)
+ errors.add(:email, "^Please enter a valid email address")
+ end
if MySociety::Validate.is_valid_email(self.name)
errors.add(:name, "^Please enter your name, not your email address, in the name field.")
end

0 comments on commit 5e2e27f

Please sign in to comment.