You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: delegate_validation.rb
    path of file: ./repos/sequencescape/app/models
    
    the code of the file until where you have to start completion: # frozen_string_literal: true
# Delegate validation is all about enabling one class to validate the information within an instance of
# another class.  The case driving this is the ability for a Submission to validate that the request options
# provided by the user a
    
  def delegate_validation(*args) # rubocop:todo Metrics/AbcSize
    options = args.extract_options!
    delegation_target = options.delete(:to) or raise StandardError, 'Cannot delegate validation without :to!'
    attribute_tag = options[:as]
    args.push(options)

    validates_each(*args) do |record, _attr, value|
      validator = record.send(:"#{delegation_target}_delegate_validator").new(value)
      validator.valid?.tap do
        validator.errors.messages.each do |attrib, message|
          record.errors.add("#{attribute_tag}.#{attrib}", message.join('; '))
        end
      end
    end
  end