from pathlib import Path


def _validate_file(path: str, file_ext: str, check_exist: bool = True) -> str:
    """Validate file path according to file_ext"""
    if not Path(path).suffix:
        path += file_ext
    if check_exist and not Path(path).exists():
        raise RuntimeError(f"File '{path}' not found.")
    if Path(path).suffix != file_ext:
        raise RuntimeError(
            f"File '{path}' extension does not match desired extension '{file_ext}'. "
        )
    return path