Coverage for src/dataknobs_fsm/config/validator.py: 100%
23 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-09-20 16:51 -0600
« prev ^ index » next coverage.py v7.10.6, created at 2025-09-20 16:51 -0600
1"""Configuration validation utilities."""
3from typing import Dict, Any, List
4from pathlib import Path
6from .schema import validate_config
7from .loader import ConfigLoader
10class ConfigValidator:
11 """Configuration validation utility."""
13 def __init__(self):
14 self.loader = ConfigLoader()
16 def validate_file(self, file_path: str) -> List[str]:
17 """Validate configuration file.
19 Args:
20 file_path: Path to configuration file
22 Returns:
23 List of validation errors (empty if valid)
24 """
25 errors = []
27 try:
28 # Try to load and validate the config - loading validates structure
29 self.loader.load_from_file(Path(file_path))
30 # If we get here, the config is valid
31 return errors
33 except Exception as e:
34 errors.append(str(e))
35 return errors
37 def validate_dict(self, config_dict: Dict[str, Any]) -> List[str]:
38 """Validate configuration dictionary.
40 Args:
41 config_dict: Configuration dictionary
43 Returns:
44 List of validation errors (empty if valid)
45 """
46 errors = []
48 try:
49 validate_config(config_dict)
50 return errors
52 except Exception as e:
53 errors.append(str(e))
54 return errors