# sec_interp.core.validation.path_validator module

Validation for file system paths and export directories.

sec_interp.core.validation.path_validator.validate_safe_output_path(path: str, base_dir: Path | None = None, must_exist: bool = False, create_if_missing: bool = False) → tuple[bool, str, Path | None]

  Validate an output path string with security and path traversal protection.

  Parameters:

    - path – Original path string to validate.

    - base_dir – Optional base directory to restrict the path to (security sandbox).

    - must_exist – If True, validation fails if the path is not currently found on disk.

    - create_if_missing – If True, attempts to create the directory if it does not exist.

  Returns:

    (is_valid, error_message, resolved_path)

      - is_valid: True if the path is safe and meets requirements.

      - error_message: Reason for validation failure.

      - resolved_path: Cleaned, absolute Path object if valid, else None.

  Return type:

    tuple

sec_interp.core.validation.path_validator.validate_output_path(path: str) → tuple[bool, str, Path | None]

  Validate that an output path is a valid directory and currently writable.

  This is a convenience wrapper around validate_safe_output_path() for general directory validation.

  Parameters:

    path – The path string to validate.

  Returns:

    (is_valid, error_message, resolved_path)

      - is_valid: True if the directory is valid and writable.

      - error_message: Error details if validation fails.

      - resolved_path: Absolute Path object if valid, else None.

  Return type:

    tuple