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

require "pakyow/validator"

module Pakyow
  module Validations
    module Data
      # Validates that the value is unique within its data source.
      #
      module Unique
        def self.message(**)
          "must be unique"
        end

        def self.valid?(value, source:, **options)
          query = options[:context].app.data.public_send(source).public_send(:"by_#{options[:key]}", value)

          if
    
        def self.valid?(value, source:, **options)
          query = options[:context].app.data.public_send(source).public_send(:"by_#{options[:key]}", value)

          if (updating = options[:updating])
            if updating.is_a?(Pakyow::Data::Result)
              query.count == 0 || query.any? { |result|
                result[updating.__proxy.source.class.primary_key_field] == updating[updating.__proxy.source.class.primary_key_field]
              }
            else
              raise ArgumentError, "Expected `#{updating.class}' to be a `Pakyow::Data::Result'"
            end