From: Shaun McDonald Date: Wed, 15 Oct 2008 16:20:43 +0000 (+0000) Subject: Adding a lower and upper length on various web site varchar fields. Fixes one test. X-Git-Tag: live~7604^2~261 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/a5e5cbc73999d004998e1e90b1b19796a94b077d Adding a lower and upper length on various web site varchar fields. Fixes one test. --- diff --git a/app/models/diary_entry.rb b/app/models/diary_entry.rb index 5b3d34766..fe48ee8dc 100644 --- a/app/models/diary_entry.rb +++ b/app/models/diary_entry.rb @@ -3,6 +3,8 @@ class DiaryEntry < ActiveRecord::Base has_many :diary_comments, :order => "id" validates_presence_of :title, :body + validates_length_of :title, :within => 1..255 + validates_length_of :language, :within => 2..3 validates_numericality_of :latitude, :allow_nil => true validates_numericality_of :longitude, :allow_nil => true validates_associated :user diff --git a/app/models/message.rb b/app/models/message.rb index ec712be25..a85de2231 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -3,6 +3,7 @@ class Message < ActiveRecord::Base belongs_to :recipient, :class_name => "User", :foreign_key => :to_user_id validates_presence_of :title, :body, :sent_on, :sender, :recipient + validates_length_of :title, :within => 1..255 validates_inclusion_of :message_read, :in => [ true, false ] validates_associated :sender, :recipient end diff --git a/app/models/trace.rb b/app/models/trace.rb index 10e867bad..1b44e2187 100644 --- a/app/models/trace.rb +++ b/app/models/trace.rb @@ -3,6 +3,8 @@ class Trace < ActiveRecord::Base validates_presence_of :user_id, :name, :timestamp validates_presence_of :description, :on => :create + validates_length_of :name, :within => 1..255 + validates_length_of :description, :within => 1..255 # validates_numericality_of :latitude, :longitude validates_inclusion_of :public, :inserted, :in => [ true, false] diff --git a/app/models/tracetag.rb b/app/models/tracetag.rb index f1d5967d5..f9833e141 100644 --- a/app/models/tracetag.rb +++ b/app/models/tracetag.rb @@ -2,6 +2,7 @@ class Tracetag < ActiveRecord::Base set_table_name 'gpx_file_tags' validates_format_of :tag, :with => /^[^\/;.,?]*$/ + validates_length_of :tag, :within => 1..255 belongs_to :trace, :foreign_key => 'gpx_id' end diff --git a/app/models/user.rb b/app/models/user.rb index 9b5bfd595..525d018ac 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -15,8 +15,9 @@ class User < ActiveRecord::Base validates_confirmation_of :pass_crypt, :message => 'Password must match the confirmation password' validates_uniqueness_of :display_name, :allow_nil => true validates_uniqueness_of :email - validates_length_of :pass_crypt, :minimum => 8 - validates_length_of :display_name, :minimum => 3, :allow_nil => true + validates_length_of :pass_crypt, :within => 8..255 + validates_length_of :display_name, :within => 3..255, :allow_nil => true + validates_length_of :email, :within => 6..255 validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i validates_format_of :display_name, :with => /^[^\/;.,?]*$/ validates_numericality_of :home_lat, :allow_nil => true diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb index 3985a527e..28ef40f1d 100644 --- a/app/models/user_preference.rb +++ b/app/models/user_preference.rb @@ -1,6 +1,9 @@ class UserPreference < ActiveRecord::Base set_primary_keys :user_id, :k belongs_to :user + + validates_length_of :k, :within => 1..255 + validates_length_of :v, :within => 1..255 # Turn this Node in to an XML Node without the wrapper. def to_xml_node