blvm_sdk/composition/
schema.rs1use crate::composition::config::NodeConfig;
6use crate::composition::types::*;
7
8pub fn validate_config_schema(config: &NodeConfig) -> Result<ValidationResult> {
10 let mut errors = Vec::new();
11 let mut warnings = Vec::new();
12
13 if config.node.name.is_empty() {
15 errors.push("Node name cannot be empty".to_string());
16 }
17
18 if !["mainnet", "testnet", "regtest"].contains(&config.node.network.as_str()) {
19 errors.push(format!(
20 "Invalid network type: {}. Must be one of: mainnet, testnet, regtest",
21 config.node.network
22 ));
23 }
24
25 for (name, module_cfg) in &config.modules {
27 if module_cfg.enabled {
28 if name.is_empty() {
29 errors.push("Module name cannot be empty".to_string());
30 }
31
32 if module_cfg.version.is_none() {
34 warnings.push(format!(
35 "Module '{name}' does not specify version, will use latest available"
36 ));
37 }
38 }
39 }
40
41 let valid = errors.is_empty();
42 Ok(ValidationResult {
43 valid,
44 errors,
45 warnings,
46 dependencies: Vec::new(), })
48}