aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/validations
diff options
context:
space:
mode:
authorSubba Rao Pasupuleti <subbarao.pasupuleti@gmail.com>2010-08-04 11:04:41 -0400
committerXavier Noria <fxn@hashref.com>2010-08-14 13:17:29 +0200
commitb61ff257e9ae4b74d4fc3b0d7d24dd15f127de1c (patch)
treee842b7f1987a3d6cd10b1a43af3969a8c3d55dda /activemodel/lib/active_model/validations
parent1577eafe77ce2a1aed3049dde34eac721b8e5aa5 (diff)
downloadrails-b61ff257e9ae4b74d4fc3b0d7d24dd15f127de1c.tar.gz
rails-b61ff257e9ae4b74d4fc3b0d7d24dd15f127de1c.tar.bz2
rails-b61ff257e9ae4b74d4fc3b0d7d24dd15f127de1c.zip
tidy up validations length code [#5297 state: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.rb8
1 files changed, 2 insertions, 6 deletions
diff --git a/activemodel/lib/active_model/validations/length.rb b/activemodel/lib/active_model/validations/length.rb
index a7af4f2b4d..ecae73a66e 100644
--- a/activemodel/lib/active_model/validations/length.rb
+++ b/activemodel/lib/active_model/validations/length.rb
@@ -41,13 +41,9 @@ module ActiveModel
CHECKS.each do |key, validity_check|
next unless check_value = options[key]
- valid_value = if key == :maximum
- value.nil? || value.size.send(validity_check, check_value)
- else
- value && value.size.send(validity_check, check_value)
- end
+ value ||= [] if key == :maximum
- next if valid_value
+ next if value && value.size.send(validity_check, check_value)
errors_options = options.except(*RESERVED_OPTIONS)
errors_options[:count] = check_value