]> git.openstreetmap.org Git - rails.git/commitdiff
Reject leading and trailing whitespace in display names
authorTom Hughes <tom@compton.nu>
Mon, 28 Jun 2010 16:47:05 +0000 (17:47 +0100)
committerTom Hughes <tom@compton.nu>
Mon, 28 Jun 2010 16:47:05 +0000 (17:47 +0100)
app/models/user.rb

index 31b0f27a03428ef9223b3c00bfe05bd89504c27f..1a50f70532184eacc6a0063c286ae135980052bf 100644 (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