code: def check_convert_string(obj, name=None,
                               no_leading_trailing_whitespace=True,
                               no_whitespace=False,
                               no_newline=True,
                               whole_word=False,
                               min_len=1,
                               max_len=0):
          
          if not name:
              name = 'Argument'
          obj = ensure_unicode(obj, name=name)
          if no_whitespace:
              if _PATTERN_WHITESPACE.match(obj):
                  raise ValueError('%s cannot contain whitespace' % name)
          elif no_leading_trailing_whitespace and _PATTERN_LEAD_TRAIL_WHITESPACE.match(obj):
              raise ValueError('%s contains leading/trailing whitespace' % name)
          if (min_len and len(obj) < min_len) or (max_len and len(obj) > max_len):
              raise ValueError('%s too short/long (%d/%d)' % (name, min_len, max_len))
          if whole_word:
              if not _PATTERN_WORD.match(obj):
                  raise ValueError('%s can only contain alphanumeric (unicode) characters, numbers and the underscore'
                                   % name)
          # whole words cannot contain newline so additional check not required
          elif no_newline and '\n' in obj:
              raise ValueError('%s cannot contain line breaks' % name)
          return obj
docs: Ensures the provided object can be interpreted as a unicode string, optionally with
             additional restrictions imposed. By default this means a non-zero length string
             which does not begin or end in whitespace.