Skip to content

Commit

Permalink
tidy up validations length code [#5297 state:resolved]
Browse files Browse the repository at this point in the history
Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information
subbarao authored and fxn committed Aug 14, 2010
1 parent 1577eaf commit b61ff25
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions activemodel/lib/active_model/validations/length.rb
Expand Up @@ -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
Expand Down

0 comments on commit b61ff25

Please sign in to comment.