pub fn validate_file_exists(path: &Path, arg_name: &str) -> Result<()>Expand description
Validate that a file or directory exists
This function checks if the given path exists on the file system. It works for both files and directories.
§Arguments
path- Path to validatearg_name- Name of the argument (for error messages)
§Returns
Ok(())if the path existsErr(ValidationError::FileNotFound)if the path doesn’t exist
§Example
use dynamic_cli::validator::file_validator::validate_file_exists;
use std::path::Path;
let path = Path::new("input.txt");
validate_file_exists(path, "input_file")?;§Error Messages
If the file doesn’t exist, the error message includes:
- The argument name
- The full path that was checked
Example: File not found for argument 'input_file': "/path/to/input.txt"