# File lib/active_record/validations.rb, line 271 def validates_each(*attrs) options = attrs.last.is_a?(Hash) ? attrs.pop.symbolize_keys : {} attrs = attrs.flatten # Declare the validation. send(validation_method(options[:on] || :save)) do |record| # Don't validate when there is an :if condition and that condition is false unless options[:if] && !evaluate_condition(options[:if], record) attrs.each do |attr| value = record.send(attr) next if value.nil? && options[:allow_nil] yield record, attr, value end end end end