diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-07-16 17:16:49 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-07-16 17:16:49 +0000 |
commit | fcefdb22bfc3a270e213e289c562bea0bd8722ef (patch) | |
tree | 17b14373e732950cc918883df746e89a33d1373d /app/models | |
parent | 7363428703e4a86c3c7b20e5adc00e9ae9428b2e (diff) | |
download | redmine-fcefdb22bfc3a270e213e289c562bea0bd8722ef.tar.gz redmine-fcefdb22bfc3a270e213e289c562bea0bd8722ef.zip |
Added several validates_length_of
git-svn-id: http://redmine.rubyforge.org/svn/trunk@593 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/attachment.rb | 4 | ||||
-rw-r--r-- | app/models/custom_field.rb | 1 | ||||
-rw-r--r-- | app/models/document.rb | 1 | ||||
-rw-r--r-- | app/models/enumeration.rb | 1 | ||||
-rw-r--r-- | app/models/issue.rb | 1 | ||||
-rw-r--r-- | app/models/issue_status.rb | 1 | ||||
-rw-r--r-- | app/models/news.rb | 2 | ||||
-rw-r--r-- | app/models/query.rb | 1 | ||||
-rw-r--r-- | app/models/role.rb | 1 | ||||
-rw-r--r-- | app/models/tracker.rb | 1 | ||||
-rw-r--r-- | app/models/version.rb | 1 |
11 files changed, 14 insertions, 1 deletions
diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 2be4e1639..b1a7c529f 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -22,7 +22,9 @@ class Attachment < ActiveRecord::Base belongs_to :author, :class_name => "User", :foreign_key => "author_id" validates_presence_of :container, :filename - + validates_length_of :filename, :maximum => 255 + validates_length_of :disk_filename, :maximum => 255 + cattr_accessor :storage_path @@storage_path = "#{RAILS_ROOT}/files" diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb index 554504a9f..751cc8526 100644 --- a/app/models/custom_field.rb +++ b/app/models/custom_field.rb @@ -29,6 +29,7 @@ class CustomField < ActiveRecord::Base validates_presence_of :name, :field_format validates_uniqueness_of :name + validates_length_of :name, :maximum => 30 validates_format_of :name, :with => /^[\w\s\'\-]*$/i validates_inclusion_of :field_format, :in => FIELD_FORMATS.keys diff --git a/app/models/document.rb b/app/models/document.rb index 141489a79..8b5d68e87 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -21,4 +21,5 @@ class Document < ActiveRecord::Base has_many :attachments, :as => :container, :dependent => :destroy validates_presence_of :project, :title, :category + validates_length_of :title, :maximum => 60 end diff --git a/app/models/enumeration.rb b/app/models/enumeration.rb index de8526067..c4f0f98cb 100644 --- a/app/models/enumeration.rb +++ b/app/models/enumeration.rb @@ -20,6 +20,7 @@ class Enumeration < ActiveRecord::Base validates_presence_of :opt, :name validates_uniqueness_of :name, :scope => [:opt] + validates_length_of :name, :maximum => 30 validates_format_of :name, :with => /^[\w\s\'\-]*$/i OPTIONS = { diff --git a/app/models/issue.rb b/app/models/issue.rb index ec62d0a01..a73160e57 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -38,6 +38,7 @@ class Issue < ActiveRecord::Base acts_as_watchable validates_presence_of :subject, :description, :priority, :tracker, :author, :status + validates_length_of :subject, :maximum => 255 validates_inclusion_of :done_ratio, :in => 0..100 validates_associated :custom_values, :on => :update diff --git a/app/models/issue_status.rb b/app/models/issue_status.rb index 3bca612aa..13ed27f6c 100644 --- a/app/models/issue_status.rb +++ b/app/models/issue_status.rb @@ -22,6 +22,7 @@ class IssueStatus < ActiveRecord::Base validates_presence_of :name validates_uniqueness_of :name + validates_length_of :name, :maximum => 30 validates_format_of :name, :with => /^[\w\s\'\-]*$/i validates_length_of :html_color, :is => 6 validates_format_of :html_color, :with => /^[a-f0-9]*$/i diff --git a/app/models/news.rb b/app/models/news.rb index cd130e96d..e9a48846a 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -21,6 +21,8 @@ class News < ActiveRecord::Base has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_on" validates_presence_of :title, :description + validates_length_of :title, :maximum => 60 + validates_length_of :summary, :maximum => 255 # returns latest news for projects visible by user def self.latest(user=nil, count=5) diff --git a/app/models/query.rb b/app/models/query.rb index b64143674..88946655f 100644 --- a/app/models/query.rb +++ b/app/models/query.rb @@ -24,6 +24,7 @@ class Query < ActiveRecord::Base attr_accessor :executed_by validates_presence_of :name, :on => :save + validates_length_of :name, :maximum => 255 @@operators = { "=" => :label_equals, "!" => :label_not_equals, diff --git a/app/models/role.rb b/app/models/role.rb index a60319c55..98d735e8e 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -24,6 +24,7 @@ class Role < ActiveRecord::Base validates_presence_of :name validates_uniqueness_of :name + validates_length_of :name, :maximum => 30 validates_format_of :name, :with => /^[\w\s\'\-]*$/i def <=>(role) diff --git a/app/models/tracker.rb b/app/models/tracker.rb index 14ac904c3..c024c0911 100644 --- a/app/models/tracker.rb +++ b/app/models/tracker.rb @@ -24,6 +24,7 @@ class Tracker < ActiveRecord::Base validates_presence_of :name validates_uniqueness_of :name + validates_length_of :name, :maximum => 30 validates_format_of :name, :with => /^[\w\s\'\-]*$/i private diff --git a/app/models/version.rb b/app/models/version.rb index 6234732d7..f4a40da67 100644 --- a/app/models/version.rb +++ b/app/models/version.rb @@ -23,6 +23,7 @@ class Version < ActiveRecord::Base validates_presence_of :name validates_uniqueness_of :name, :scope => [:project_id] + validates_length_of :name, :maximum => 30 validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :activerecord_error_not_a_date, :allow_nil => true def start_date |