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: indexes.rb
    path of file: ./repos/dynamoid/lib/dynamoid
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

module Dynamoid
  module Indexes
    extend ActiveS
    
      def validate_index_key(key_param, key_val)
        return if key_val.blank?

        key_field_attributes = @dynamoid_class.attributes[key_val]
        if key_field_attributes.blank?
          errors.add(key_param, "No such field #{key_val} defined on table")
          return
        end