12 lines
299 B
Python
12 lines
299 B
Python
def parse_cat_id(value: str) -> int | None | bool:
|
|
if value == "root":
|
|
return None
|
|
if str(value).isdigit():
|
|
return int(value)
|
|
|
|
raise Exception("Invalid Category Id.")
|
|
|
|
|
|
def serialize_cat_id(cat_id: int | None) -> str:
|
|
return "root" if cat_id is None else str(cat_id)
|