Skip to main content

validate_file_path_in_project

Function validate_file_path_in_project 

Source
pub fn validate_file_path_in_project(
    path: &Path,
    project_root: &Path,
) -> PatternsResult<PathBuf>
Expand description

Validate a file path ensuring it stays within a project root.

This is stricter than validate_file_path - it ensures the resolved path is a descendant of the project root directory.

§Arguments

  • path - The path to validate
  • project_root - The project root directory to stay within

§Returns

The canonicalized path if valid and within project root.

§Errors

  • PatternsError::FileNotFound if the file doesn’t exist
  • PatternsError::PathTraversal if path escapes project root