docs: def sanitize_network(network, ip_version):
      """
      :return: Network string
      :rtype: str
      :raises ValueError: if the network string is invalid.
      """
  
      import ipaddress
  
      if typepy.is_null_string(network) or network.lower() == "anywhere":
          return get_anywhere_network(ip_version)
  
      try:
          if ip_version == 4:
              ipaddress.IPv4Address(network)
              return network + "/32"
  
          if ip_version == 6:
              return ipaddress.IPv6Address(network).compressed
      except ipaddress.AddressValueError:
          pass
  
      # validate network str ---
  
      if ip_version == 4:
          return ipaddress.IPv4Network(six.text_type(network)).compressed
  
      if ip_version == 6:
          return ipaddress.IPv6Network(six.text_type(network)).compressed
  
      raise ValueError("unexpected ip version: {}".format(ip_version))