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:
parent
90a7915ab2
commit
e82b38cd57
1 changed files with 2 additions and 6 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue