def is_temp_id(val): return ( val is None or (isinstance(val, int) and val < 0) or (isinstance(val, str) and val.startswith("temp-")) )