import re

from typing import Optional, Any

CATEGORY_REGEX = re.compile(r"^([\w\-._]+( > [\w\-._]+)?)+$")


def is_category(value: Optional[Any]) -> bool:
  if not value or not isinstance(value, str):
    return False
  return CATEGORY_REGEX.fullmatch(value) is not None
