class ActiveRecord::Validations::AssociatedValidator
def validate_each(record, attribute, value)
def validate_each(record, attribute, value) context = record_validation_context_for_association(record) if Array(value).reject { |association| valid_object?(association, context) }.any? record.errors.add(attribute, :invalid, **options.merge(value: value)) end end