Skip to content
This repository
Browse code

tidy up validations length code [#5297 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
commit e82b38cd578aa316a03dae55df8076c4b2111bb6 1 parent 90a7915
Subba Rao Pasupuleti authored August 04, 2010 josevalim committed August 12, 2010
8  activemodel/lib/active_model/validations/length.rb
@@ -41,13 +41,9 @@ def validate_each(record, attribute, value)
41 41
         CHECKS.each do |key, validity_check|
42 42
           next unless check_value = options[key]
43 43
 
44  
-          valid_value = if key == :maximum
45  
-            value.nil? || value.size.send(validity_check, check_value)
46  
-          else
47  
-            value && value.size.send(validity_check, check_value)
48  
-          end
  44
+          value ||= [] if key == :maximum
49 45
 
50  
-          next if valid_value
  46
+          next if value && value.size.send(validity_check, check_value)
51 47
 
52 48
           errors_options = options.except(*RESERVED_OPTIONS)
53 49
           errors_options[:count] = check_value

0 notes on commit e82b38c

Please sign in to comment.
Something went wrong with that request. Please try again.