code: def host_validator(value, **kwargs):
      
      scheme, hostname, port, path = decompose_hostname(value)
  
      if len(hostname) > 255:
          return False
      if hostname[-1] == ".":
          hostname = hostname[:-1]  # strip exactly one dot from the right, if present
      allowed = re.compile("(?!-)[A-Z\d-]{1,63}(?<!-)$", re.IGNORECASE)
  
      with ErrorDict() as errors:
          if not all(allowed.match(x) for x in hostname.split(".")):
              errors.add_error(
                  'invalid',
                  MESSAGES['host']['invalid'].format(value),
              )
  
          if path:
              errors.add_error(
                  'path',
                  MESSAGES['host']['may_not_include_path'].format(value),
              )
  
          if scheme:
              errors.add_error(
                  'scheme',
                  MESSAGES['host']['may_not_include_scheme'].format(value),
              )
docs: From: http://stackoverflow.com/questions/2532053/validate-a-hostname-string
      According to: http://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names