def validate_path(path: str | Path) -> str:
    """Validate a single input path.

    This function validates and normalizes file system paths. It accepts string paths or
    ``pathlib.Path`` objects and converts them to string format.

    Args:
        path (``str`` | ``Path``): Input path to validate. Can be a string path or
            ``pathlib.Path`` object.

    Returns:
        ``str``: The validated path as a string.

    Raises:
        TypeError: If ``path`` is not a string or ``Path`` object.

    Examples:
        Validate a string path::

            >>> validate_path("/path/to/file.png")
            '/path/to/file.png'

        Validate a Path object::

            >>> from pathlib import Path
            >>> validate_path(Path("/path/to/file.png"))
            '/path/to/file.png'

        Invalid input raises TypeError::

            >>> validate_path(123)
            Traceback (most recent call last):
                ...
            TypeError: Path must be None, a string, or Path object, got <class 'int'>.
    """
    if isinstance(path, str | Path):
        return str(path)
    msg = f"Path must be None, a string, or Path object, got {type(path)}."
    raise TypeError(msg)
Validate a single input path.

    This function validates and normalizes file system paths. It accepts string paths or
    ``pathlib.Path`` objects and converts them to string format.

    Args:
        path (``str`` | ``Path``): Input path to validate. Can be a string path or
            ``pathlib.Path`` object.

    Returns:
        ``str``: The validated path as a string.

    Raises:
        TypeError: If ``path`` is not a string or ``Path`` object.

    Examples:
        Validate a string path::

            >>> validate_path("/path/to/file.png")
            '/path/to/file.png'

        Validate a Path object::

            >>> from pathlib import Path
            >>> validate_path(Path("/path/to/file.png"))
            '/path/to/file.png'

        Invalid input raises TypeError::

            >>> validate_path(123)
            Traceback (most recent call last):
                ...
            TypeError: Path must be None, a string, or Path object, got <class 'int'>.
    
src/anomalib/data/validators/path.py