Reject leading and trailing whitespace in display names

This commit is contained in:
Tom Hughes 2010-06-28 17:47:05 +01:00
parent 98d73aead1
commit b4a22eee71

View file

@ -28,6 +28,8 @@ class User < ActiveRecord::Base
validates_email_format_of :email
validates_email_format_of :new_email, :allow_blank => true
validates_format_of :display_name, :with => /^[^\/;.,?]*$/
validates_format_of :display_name, :with => /^\S/, :message => "has leading whitespace"
validates_format_of :display_name, :with => /\S$/, :message => "has trailing whitespace"
validates_numericality_of :home_lat, :allow_nil => true
validates_numericality_of :home_lon, :allow_nil => true
validates_numericality_of :home_zoom, :only_integer => true, :allow_nil => true