mirror of https://github.com/rails/rails
tidy up validations length code [#5297 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
parent
90a7915ab2
commit
e82b38cd57
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue