Permalink
Browse files

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

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent d03a124 commit 9df227983f08a2f46725f5909ab3b85e7b206c98 @subbarao subbarao committed with josevalim Aug 4, 2010
Showing with 2 additions and 6 deletions.
  1. +2 −6 activemodel/lib/active_model/validations/length.rb
@@ -41,13 +41,9 @@ def validate_each(record, attribute, value)
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

0 comments on commit 9df2279

Please sign in to comment.