1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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

View file

@ -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