def check_is_fid_valid(fid, raise_exception=True):
    """
    Check if FID is well formed

    :param fid: functional ID
    :param raise_exception: Indicate if an exception shall be raised (True, default) or not (False)

    :type fid: str
    :type raise_exception: bool

    :returns: the status of the check
    :rtype: bool

    :raises TypeError: if FID is invalid
    :raises ValueError: if FID is not well formatted
    """
    if fid is None:
        if raise_exception:
            raise ValueError("FID shall be set")
        return False
    if not isinstance(fid, str):
        if raise_exception:
            raise TypeError("Type of fid: '%s' shall be str, not %s" % (fid, type(fid)))
        return False
    if len(fid) < 3:
        if raise_exception:
            raise ValueError("fid shall have at least 3 characters: '%s'" % fid)
        return False
    if " " in fid:
        if raise_exception:
            raise ValueError("fid shall not contains spaces: '%s'" % fid)
        return False
    return True