pub fn validate_file_extension(
path: &Path,
arg_name: &str,
allowed: &[String],
) -> Result<()>Expand description
Validate that a file has an allowed extension.
The comparison is case-insensitive. Extensions should be provided
without the leading dot (e.g., "yaml", not ".yaml").
§Arguments
path- The path whose extension to checkarg_name- The argument name (used in error messages)allowed- List of allowed extensions (without leading dot)
§Returns
Ok(())if the extension is in the allowed listErr(ValidationError::InvalidExtension)otherwise
§Example
use dynamic_cli::validator::validate_file_extension;
use std::path::Path;
let allowed = vec!["yaml".to_string(), "yml".to_string()];
validate_file_extension(Path::new("config.yaml"), "config", &allowed)?;