Skip to main content

validate_config

Function validate_config 

Source
pub fn validate_config(config: &CommandsConfig) -> Result<()>
Expand description

Validate the entire configuration

Performs comprehensive validation of the configuration structure, checking for:

  • Duplicate command names and aliases
  • Valid argument types
  • Consistent validation rules
  • Option/argument naming conflicts
  • Command names and aliases starting with :, which is reserved for REPL directives
  • REPL directive overrides (see crate::config::directive): each directive overridden at most once; names and aliases non-empty, without whitespace or leading :; names and aliases unique across the directive table after merging with the defaults

§Arguments

  • config - The configuration to validate

§Errors

§Example

use dynamic_cli::config::schema::{CommandsConfig, Metadata};
use dynamic_cli::config::validator::validate_config;

      metadata: Metadata {
        version: "1.0.0".to_string(),
        prompt: "test".to_string(),
        prompt_suffix: " >".to_string()
        },
      commands: vec![],
      global_options: vec![],
      directives: vec![],
};
// After loading configuration
validate_config(&config)?;