diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-01-05 16:09:15 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-01-05 16:09:15 +0000 |
commit | 3e14c3017c037d93e562c3697cf50224dced7b50 (patch) | |
tree | d62163eba0051d645d1c7b17e55c434f05a737da /app/models/version.rb | |
parent | 6ed7e091dfc833830ccd0e689714913c81ef6d22 (diff) | |
download | redmine-3e14c3017c037d93e562c3697cf50224dced7b50.tar.gz redmine-3e14c3017c037d93e562c3697cf50224dced7b50.zip |
Adds a custom validator for dates (#12736).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11124 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/version.rb')
-rw-r--r-- | app/models/version.rb | 9 |
1 files changed, 1 insertions, 8 deletions
diff --git a/app/models/version.rb b/app/models/version.rb index 50225f362..e7651ad23 100644 --- a/app/models/version.rb +++ b/app/models/version.rb @@ -30,10 +30,9 @@ class Version < ActiveRecord::Base validates_presence_of :name validates_uniqueness_of :name, :scope => [:project_id] validates_length_of :name, :maximum => 60 - validates_format_of :effective_date, :with => /\A\d{4}-\d{2}-\d{2}\z/, :message => :not_a_date, :allow_nil => true + validates :effective_date, :date => true validates_inclusion_of :status, :in => VERSION_STATUSES validates_inclusion_of :sharing, :in => VERSION_SHARINGS - validate :validate_version scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)} scope :open, lambda { where(:status => 'open') } @@ -287,10 +286,4 @@ class Version < ActiveRecord::Base progress end end - - def validate_version - if effective_date.nil? && @attributes['effective_date'].present? - errors.add :effective_date, :not_a_date - end - end end |