code: def require_string(obj, name=None, nonempty=False):
      
      require_instance(obj, string_types, name, "string")
      if nonempty and not obj:
          raise ValueError(
              (("%s: " % name) if name else "") +
              "string must be nonempty.")
docs: Raise an exception if the obj is not of type str or unicode.
  
      If name is provided it is used in the exception message.
  
      If nonempty=True, then an exception is raised if the object is the empty
      string.