##// END OF EJS Templates
Added several validates_length_of...
Jean-Philippe Lang -
r590:fcefdb22bfc3
parent child
Show More
@@ -22,7 +22,9 class Attachment < ActiveRecord::Base
22 belongs_to :author, :class_name => "User", :foreign_key => "author_id"
22 belongs_to :author, :class_name => "User", :foreign_key => "author_id"
23
23
24 validates_presence_of :container, :filename
24 validates_presence_of :container, :filename
25
25 validates_length_of :filename, :maximum => 255
26 validates_length_of :disk_filename, :maximum => 255
27
26 cattr_accessor :storage_path
28 cattr_accessor :storage_path
27 @@storage_path = "#{RAILS_ROOT}/files"
29 @@storage_path = "#{RAILS_ROOT}/files"
28
30
@@ -29,6 +29,7 class CustomField < ActiveRecord::Base
29
29
30 validates_presence_of :name, :field_format
30 validates_presence_of :name, :field_format
31 validates_uniqueness_of :name
31 validates_uniqueness_of :name
32 validates_length_of :name, :maximum => 30
32 validates_format_of :name, :with => /^[\w\s\'\-]*$/i
33 validates_format_of :name, :with => /^[\w\s\'\-]*$/i
33 validates_inclusion_of :field_format, :in => FIELD_FORMATS.keys
34 validates_inclusion_of :field_format, :in => FIELD_FORMATS.keys
34
35
@@ -21,4 +21,5 class Document < ActiveRecord::Base
21 has_many :attachments, :as => :container, :dependent => :destroy
21 has_many :attachments, :as => :container, :dependent => :destroy
22
22
23 validates_presence_of :project, :title, :category
23 validates_presence_of :project, :title, :category
24 validates_length_of :title, :maximum => 60
24 end
25 end
@@ -20,6 +20,7 class Enumeration < ActiveRecord::Base
20
20
21 validates_presence_of :opt, :name
21 validates_presence_of :opt, :name
22 validates_uniqueness_of :name, :scope => [:opt]
22 validates_uniqueness_of :name, :scope => [:opt]
23 validates_length_of :name, :maximum => 30
23 validates_format_of :name, :with => /^[\w\s\'\-]*$/i
24 validates_format_of :name, :with => /^[\w\s\'\-]*$/i
24
25
25 OPTIONS = {
26 OPTIONS = {
@@ -38,6 +38,7 class Issue < ActiveRecord::Base
38 acts_as_watchable
38 acts_as_watchable
39
39
40 validates_presence_of :subject, :description, :priority, :tracker, :author, :status
40 validates_presence_of :subject, :description, :priority, :tracker, :author, :status
41 validates_length_of :subject, :maximum => 255
41 validates_inclusion_of :done_ratio, :in => 0..100
42 validates_inclusion_of :done_ratio, :in => 0..100
42 validates_associated :custom_values, :on => :update
43 validates_associated :custom_values, :on => :update
43
44
@@ -22,6 +22,7 class IssueStatus < ActiveRecord::Base
22
22
23 validates_presence_of :name
23 validates_presence_of :name
24 validates_uniqueness_of :name
24 validates_uniqueness_of :name
25 validates_length_of :name, :maximum => 30
25 validates_format_of :name, :with => /^[\w\s\'\-]*$/i
26 validates_format_of :name, :with => /^[\w\s\'\-]*$/i
26 validates_length_of :html_color, :is => 6
27 validates_length_of :html_color, :is => 6
27 validates_format_of :html_color, :with => /^[a-f0-9]*$/i
28 validates_format_of :html_color, :with => /^[a-f0-9]*$/i
@@ -21,6 +21,8 class News < ActiveRecord::Base
21 has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_on"
21 has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_on"
22
22
23 validates_presence_of :title, :description
23 validates_presence_of :title, :description
24 validates_length_of :title, :maximum => 60
25 validates_length_of :summary, :maximum => 255
24
26
25 # returns latest news for projects visible by user
27 # returns latest news for projects visible by user
26 def self.latest(user=nil, count=5)
28 def self.latest(user=nil, count=5)
@@ -24,6 +24,7 class Query < ActiveRecord::Base
24 attr_accessor :executed_by
24 attr_accessor :executed_by
25
25
26 validates_presence_of :name, :on => :save
26 validates_presence_of :name, :on => :save
27 validates_length_of :name, :maximum => 255
27
28
28 @@operators = { "=" => :label_equals,
29 @@operators = { "=" => :label_equals,
29 "!" => :label_not_equals,
30 "!" => :label_not_equals,
@@ -24,6 +24,7 class Role < ActiveRecord::Base
24
24
25 validates_presence_of :name
25 validates_presence_of :name
26 validates_uniqueness_of :name
26 validates_uniqueness_of :name
27 validates_length_of :name, :maximum => 30
27 validates_format_of :name, :with => /^[\w\s\'\-]*$/i
28 validates_format_of :name, :with => /^[\w\s\'\-]*$/i
28
29
29 def <=>(role)
30 def <=>(role)
@@ -24,6 +24,7 class Tracker < ActiveRecord::Base
24
24
25 validates_presence_of :name
25 validates_presence_of :name
26 validates_uniqueness_of :name
26 validates_uniqueness_of :name
27 validates_length_of :name, :maximum => 30
27 validates_format_of :name, :with => /^[\w\s\'\-]*$/i
28 validates_format_of :name, :with => /^[\w\s\'\-]*$/i
28
29
29 private
30 private
@@ -23,6 +23,7 class Version < ActiveRecord::Base
23
23
24 validates_presence_of :name
24 validates_presence_of :name
25 validates_uniqueness_of :name, :scope => [:project_id]
25 validates_uniqueness_of :name, :scope => [:project_id]
26 validates_length_of :name, :maximum => 30
26 validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :activerecord_error_not_a_date, :allow_nil => true
27 validates_format_of :effective_date, :with => /^\d{4}-\d{2}-\d{2}$/, :message => :activerecord_error_not_a_date, :allow_nil => true
27
28
28 def start_date
29 def start_date
General Comments 0
You need to be logged in to leave comments. Login now