##// END OF EJS Templates
Add length validations for string fields (#24283)....
Jean-Philippe Lang -
r15607:7b3f2b51c0ea
parent child
Show More
@@ -32,6 +32,7 class CustomField < ActiveRecord::Base
32 validates_presence_of :name, :field_format
32 validates_presence_of :name, :field_format
33 validates_uniqueness_of :name, :scope => :type
33 validates_uniqueness_of :name, :scope => :type
34 validates_length_of :name, :maximum => 30
34 validates_length_of :name, :maximum => 30
35 validates_length_of :regexp, maximum: 30
35 validates_inclusion_of :field_format, :in => Proc.new { Redmine::FieldFormat.available_formats }
36 validates_inclusion_of :field_format, :in => Proc.new { Redmine::FieldFormat.available_formats }
36 validate :validate_custom_field
37 validate :validate_custom_field
37 attr_protected :id
38 attr_protected :id
@@ -37,7 +37,9 class Repository < ActiveRecord::Base
37 # has_many :changesets, :dependent => :destroy is too slow for big repositories
37 # has_many :changesets, :dependent => :destroy is too slow for big repositories
38 before_destroy :clear_changesets
38 before_destroy :clear_changesets
39
39
40 validates_length_of :login, maximum: 60, allow_nil: true
40 validates_length_of :password, :maximum => 255, :allow_nil => true
41 validates_length_of :password, :maximum => 255, :allow_nil => true
42 validates_length_of :root_url, :url, maximum: 255
41 validates_length_of :identifier, :maximum => IDENTIFIER_MAX_LENGTH, :allow_blank => true
43 validates_length_of :identifier, :maximum => IDENTIFIER_MAX_LENGTH, :allow_blank => true
42 validates_uniqueness_of :identifier, :scope => :project_id
44 validates_uniqueness_of :identifier, :scope => :project_id
43 validates_exclusion_of :identifier, :in => %w(browse show entry raw changes annotate diff statistics graph revisions revision)
45 validates_exclusion_of :identifier, :in => %w(browse show entry raw changes annotate diff statistics graph revisions revision)
@@ -111,6 +111,7 class User < Principal
111 validates_format_of :login, :with => /\A[a-z0-9_\-@\.]*\z/i
111 validates_format_of :login, :with => /\A[a-z0-9_\-@\.]*\z/i
112 validates_length_of :login, :maximum => LOGIN_LENGTH_LIMIT
112 validates_length_of :login, :maximum => LOGIN_LENGTH_LIMIT
113 validates_length_of :firstname, :lastname, :maximum => 30
113 validates_length_of :firstname, :lastname, :maximum => 30
114 validates_length_of :identity_url, maximum: 255
114 validates_inclusion_of :mail_notification, :in => MAIL_NOTIFICATION_OPTIONS.collect(&:first), :allow_blank => true
115 validates_inclusion_of :mail_notification, :in => MAIL_NOTIFICATION_OPTIONS.collect(&:first), :allow_blank => true
115 validate :validate_password_length
116 validate :validate_password_length
116 validate do
117 validate do
@@ -35,7 +35,7 class Version < ActiveRecord::Base
35 validates_presence_of :name
35 validates_presence_of :name
36 validates_uniqueness_of :name, :scope => [:project_id]
36 validates_uniqueness_of :name, :scope => [:project_id]
37 validates_length_of :name, :maximum => 60
37 validates_length_of :name, :maximum => 60
38 validates_length_of :description, :maximum => 255
38 validates_length_of :description, :wiki_page_title, :maximum => 255
39 validates :effective_date, :date => true
39 validates :effective_date, :date => true
40 validates_inclusion_of :status, :in => VERSION_STATUSES
40 validates_inclusion_of :status, :in => VERSION_STATUSES
41 validates_inclusion_of :sharing, :in => VERSION_SHARINGS
41 validates_inclusion_of :sharing, :in => VERSION_SHARINGS
@@ -25,6 +25,7 class Wiki < ActiveRecord::Base
25
25
26 validates_presence_of :start_page
26 validates_presence_of :start_page
27 validates_format_of :start_page, :with => /\A[^,\.\/\?\;\|\:]*\z/
27 validates_format_of :start_page, :with => /\A[^,\.\/\?\;\|\:]*\z/
28 validates_length_of :title, maximum: 255
28 attr_protected :id
29 attr_protected :id
29
30
30 before_destroy :delete_redirects
31 before_destroy :delete_redirects
@@ -45,6 +45,7 class WikiPage < ActiveRecord::Base
45 validates_presence_of :title
45 validates_presence_of :title
46 validates_format_of :title, :with => /\A[^,\.\/\?\;\|\s]*\z/
46 validates_format_of :title, :with => /\A[^,\.\/\?\;\|\s]*\z/
47 validates_uniqueness_of :title, :scope => :wiki_id, :case_sensitive => false
47 validates_uniqueness_of :title, :scope => :wiki_id, :case_sensitive => false
48 validates_length_of :title, maximum: 255
48 validates_associated :content
49 validates_associated :content
49 attr_protected :id
50 attr_protected :id
50
51
General Comments 0
You need to be logged in to leave comments. Login now