aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/validations
diff options
context:
space:
mode:
authorjzw <zac@zacwilliams.com>2009-08-05 20:17:59 -0500
committerPratik Naik <pratiknaik@gmail.com>2009-08-08 19:08:13 +0100
commit5ab94b2595836fe2de36fd632ba9577c459b1292 (patch)
tree6de1b8be18c5869c5ba524606ad3227a4dcb7d36 /activemodel/lib/active_model/validations
parentc34d6279a06c80c51eefc3d345c24eab9a1e44fe (diff)
downloadrails-5ab94b2595836fe2de36fd632ba9577c459b1292.tar.gz
rails-5ab94b2595836fe2de36fd632ba9577c459b1292.tar.bz2
rails-5ab94b2595836fe2de36fd632ba9577c459b1292.zip
validates_length_of with maximum should allow nil [#2309 status:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'activemodel/lib/active_model/validations')
-rw-r--r--activemodel/lib/active_model/validations/length.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/validations/length.rb b/activemodel/lib/active_model/validations/length.rb
index db0439d447..81c97238d2 100644
--- a/activemodel/lib/active_model/validations/length.rb
+++ b/activemodel/lib/active_model/validations/length.rb
@@ -80,8 +80,10 @@ module ActiveModel
validates_each(attrs, options) do |record, attr, value|
value = options[:tokenizer].call(value) if value.kind_of?(String)
- unless !value.nil? and value.size.method(validity_checks[option])[option_value]
- record.errors.add(attr, key, :default => custom_message, :count => option_value)
+ unless option == :maximum and value.nil?
+ unless !value.nil? and value.size.send(validity_checks[option], option_value)
+ record.errors.add(attr, key, :default => custom_message, :count => option_value)
+ end
end
end
end