Method: ActiveModel::Validations::ArrayValidator#validate_each

Defined in:
lib/can_has_validations/validators/array_validator.rb

#validate_each(record, attribute, array_values) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/can_has_validations/validators/array_validator.rb', line 71

def validate_each(record, attribute, array_values)
  @validators.each do |validator|
    error_count = count_errors(record)

    Array(array_values).each do |value|
      validate_one(validator, record, attribute, value)

      # to avoid repeating error messages, stop after a single error
      unless validator.options[:multiple_errors]
        break if error_count != count_errors(record)
      end
    end
  end
end