[openstreetmap-website] Error: Display Name is invalid (#157)
Simon Legner
notifications at github.com
Mon Nov 12 17:25:36 GMT 2012
The error "Display Name is invalid" while registering might not be too helpful. Instead, display which characters are not allowed (I'm not completely sure about the handling of `\/`):
```diff
diff --git a/app/models/user.rb b/app/models/user.rb
index 3b43130..27662f1 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -36,7 +36,7 @@ class User < ActiveRecord::Base
validates_length_of :display_name, :within => 3..255, :allow_nil => true
validates_email_format_of :email, :if => Proc.new { |u| u.email_changed? }
validates_email_format_of :new_email, :allow_blank => true, :if => Proc.new { |u| u.new_email_changed? }
- validates_format_of :display_name, :with => /^[^\/;.,?%#]*$/, :if => Proc.new { |u| u.display_name_changed? }
+ validates_format_of :display_name, :with => /^[^\/;.,?%#]*$/, :message => "contains invalid characters (\/;.,?%#)" :if => Proc.new { |u| u.display_name_changed? }
validates_format_of :display_name, :with => /^\S/, :message => "has leading whitespace", :if => Proc.new { |u| u.display_name_changed? }
validates_format_of :display_name, :with => /\S$/, :message => "has trailing whitespace", :if => Proc.new { |u| u.display_name_changed? }
validates_numericality_of :home_lat, :allow_nil => true
```
---
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/issues/157
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20121112/5ce99dde/attachment.html>
More information about the rails-dev
mailing list