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

Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
Subba Rao Pasupuleti 2010-08-04 11:04:41 -04:00 committed by José Valim
parent 90a7915ab2
commit e82b38cd57
1 changed files with 2 additions and 6 deletions

View File

@ -41,13 +41,9 @@ module ActiveModel
CHECKS.each do |key, validity_check| CHECKS.each do |key, validity_check|
next unless check_value = options[key] next unless check_value = options[key]
valid_value = if key == :maximum value ||= [] if key == :maximum
value.nil? || value.size.send(validity_check, check_value)
else
value && value.size.send(validity_check, check_value)
end
next if valid_value next if value && value.size.send(validity_check, check_value)
errors_options = options.except(*RESERVED_OPTIONS) errors_options = options.except(*RESERVED_OPTIONS)
errors_options[:count] = check_value errors_options[:count] = check_value