Skip to content

Commit

Permalink
validate_each in NumericalityValidator is never called in this case.
Browse files Browse the repository at this point in the history
NumericalityValidator#validate_each is never called when allow_nil is true and
the value is nil because it is already skipped in EachValidator#validate.
  • Loading branch information
guilleiguaran committed Aug 28, 2016
1 parent 43f1b23 commit cec60d3
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions activemodel/lib/active_model/validations/numericality.rb
Expand Up @@ -26,8 +26,6 @@ def validate_each(record, attr_name, value)
raw_value = value raw_value = value
end end


return if options[:allow_nil] && raw_value.nil?

unless is_number?(raw_value) unless is_number?(raw_value)
record.errors.add(attr_name, :not_a_number, filtered_options(raw_value)) record.errors.add(attr_name, :not_a_number, filtered_options(raw_value))
return return
Expand Down

0 comments on commit cec60d3

Please sign in to comment.