diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-04-02 18:44:35 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-04-02 18:44:35 +0000 |
commit | 791077c240f74dd4e228fc5b8ac3d7a0c0d41f3a (patch) | |
tree | e53f43445c12850481f1a9df0e7929eaa0ae805f /app | |
parent | bd8de9a6f84052f72930dac3c5ee2e353c249238 (diff) | |
download | redmine-791077c240f74dd4e228fc5b8ac3d7a0c0d41f3a.tar.gz redmine-791077c240f74dd4e228fc5b8ac3d7a0c0d41f3a.zip |
Added some attributes length validations.
Also added some information about attribute length constraints on forms.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@400 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/models/project.rb | 4 | ||||
-rw-r--r-- | app/models/user.rb | 5 | ||||
-rw-r--r-- | app/views/account/password_recovery.rhtml | 3 | ||||
-rw-r--r-- | app/views/my/account.rhtml | 3 | ||||
-rw-r--r-- | app/views/projects/_form.rhtml | 6 | ||||
-rw-r--r-- | app/views/users/_form.rhtml | 3 |
6 files changed, 16 insertions, 8 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 2419e720d..60a376768 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -35,8 +35,10 @@ class Project < ActiveRecord::Base validates_uniqueness_of :name, :identifier validates_associated :custom_values, :on => :update validates_associated :repository, :wiki + validates_length_of :name, :maximum => 30 validates_format_of :name, :with => /^[\w\s\'\-]*$/i - validates_length_of :identifier, :maximum => 12 + validates_length_of :description, :maximum => 255 + validates_length_of :identifier, :in => 3..12 validates_format_of :identifier, :with => /^[a-z0-9\-]*$/ def identifier=(identifier) diff --git a/app/models/user.rb b/app/models/user.rb index 869be920e..08220beaa 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -33,9 +33,12 @@ class User < ActiveRecord::Base validates_presence_of :login, :firstname, :lastname, :mail validates_uniqueness_of :login, :mail # Login must contain lettres, numbers, underscores only - validates_format_of :firstname, :lastname, :with => /^[\w\s\'\-]*$/i validates_format_of :login, :with => /^[a-z0-9_\-@\.]+$/i + validates_length_of :login, :maximum => 30 + validates_format_of :firstname, :lastname, :with => /^[\w\s\'\-]*$/i + validates_length_of :firstname, :lastname, :maximum => 30 validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i + validates_length_of :mail, :maximum => 60 # Password length between 4 and 12 validates_length_of :password, :in => 4..12, :allow_nil => true validates_confirmation_of :password, :allow_nil => true diff --git a/app/views/account/password_recovery.rhtml b/app/views/account/password_recovery.rhtml index 89b105292..c3c451e57 100644 --- a/app/views/account/password_recovery.rhtml +++ b/app/views/account/password_recovery.rhtml @@ -9,7 +9,8 @@ <% form_tag({:token => @token.value}, :class => "tabular") do %> <p><label for="new_password"><%=l(:field_new_password)%> <span class="required">*</span></label> - <%= password_field_tag 'new_password', nil, :size => 25 %></p> + <%= password_field_tag 'new_password', nil, :size => 25 %><br /> + <em><%= l(:text_length_between, 4, 12) %></em></p> <p><label for="new_password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label> <%= password_field_tag 'new_password_confirmation', nil, :size => 25 %></p> diff --git a/app/views/my/account.rhtml b/app/views/my/account.rhtml index 8a1468cd5..24f0ef551 100644 --- a/app/views/my/account.rhtml +++ b/app/views/my/account.rhtml @@ -35,7 +35,8 @@ <%= password_field_tag 'password', nil, :size => 25 %></p> <p><label for="new_password"><%=l(:field_new_password)%> <span class="required">*</span></label> - <%= password_field_tag 'new_password', nil, :size => 25 %></p> + <%= password_field_tag 'new_password', nil, :size => 25 %><br /> + <em><%= l(:text_length_between, 4, 12) %></em></p> <p><label for="new_password_confirmation"><%=l(:field_password_confirmation)%> <span class="required">*</span></label> <%= password_field_tag 'new_password_confirmation', nil, :size => 25 %></p> diff --git a/app/views/projects/_form.rhtml b/app/views/projects/_form.rhtml index 184370b92..03a757d70 100644 --- a/app/views/projects/_form.rhtml +++ b/app/views/projects/_form.rhtml @@ -2,14 +2,14 @@ <div class="box"> <!--[form:project]--> -<p><%= f.text_field :name, :required => true %></p> +<p><%= f.text_field :name, :required => true %><br /><em><%= l(:text_caracters_maximum, 30) %></em></p> <% if admin_loggedin? and !@root_projects.empty? %> <p><%= f.select :parent_id, (@root_projects.collect {|p| [p.name, p.id]}), { :include_blank => true } %></p> <% end %> -<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 3 %></p> -<p><%= f.text_field :identifier, :required => true, :size => 15, :disabled => @project.identifier_frozen? %><br /><em><%= l(:text_project_identifier_info) unless @project.identifier_frozen? %></em></p> +<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 3 %><br /><em><%= l(:text_caracters_maximum, 255) %></em></p> +<p><%= f.text_field :identifier, :required => true, :size => 15, :disabled => @project.identifier_frozen? %><br /><em><%= l(:text_length_between, 3, 12) %> <%= l(:text_project_identifier_info) unless @project.identifier_frozen? %></em></p> <p><%= f.text_field :homepage, :size => 40 %></p> <p><%= f.check_box :is_public %></p> diff --git a/app/views/users/_form.rhtml b/app/views/users/_form.rhtml index 18c849257..43540e67c 100644 --- a/app/views/users/_form.rhtml +++ b/app/views/users/_form.rhtml @@ -23,7 +23,8 @@ <p><%= f.select :auth_source_id, [[l(:label_internal), ""]] + @auth_sources.collect { |a| [a.name, a.id] } %></p> <% end %> <p><label for="password"><%=l(:field_password)%><span class="required"> *</span></label> -<%= password_field_tag 'password', nil, :size => 25 %></p> +<%= password_field_tag 'password', nil, :size => 25 %><br /> +<em><%= l(:text_length_between, 4, 12) %></em></p> <p><label for="password_confirmation"><%=l(:field_password_confirmation)%><span class="required"> *</span></label> <%= password_field_tag 'password_confirmation', nil, :size => 25 %></p> </div> |