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: validator.rb
    path of file: ./repos/mongo-ruby-driver/lib/mongo/address
    
    the code of the file until where you have to start completion: # frozen_string_literal: true
# rubocop:todo all

# Copyright (C) 2017-2020 MongoDB Inc.
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an 'AS IS' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

module Mongo

  class Address

    # @api private
    module Validator

      # Takes an address string in ipv4/ipv6/hostname/socket path format
    
      def validate_hostname!(host)
        # Since we are performing same origin verification during SRV
        # processing, prohibit leading dots in hostnames, trailing dots
        # and runs of multiple dots. DNS resolution of SRV records yields
        # hostnames with trailing dots, those trailing dots are removed
        # during normalization process prior to validation.
        if host.start_with?('.')
          raise Error::InvalidAddress, "Hostname cannot start with a dot: #{host}"
        end
        if host.end_with?('.')
          raise Error::InvalidAddress, "Hostname cannot end with a dot: #{host}"
        end
        if host.include?('..')
          raise Error::InvalidAddress, "Runs of multiple dots are not allowed in hostname: #{host}"
        end
      end

      def validate_port_str!(port)
        unless port.nil? || (port.length > 0 && port.to_i > 0 && port.to_i <= 65535)
          raise Error::InvalidAddress,
            "Invalid port: #{port}. Port must be an integer greater than 0 and less than 65536"
        end
      end
    end
  end