Coverage for src/dataknobs_fsm/config/validator.py: 0%

1"""Configuration validation utilities."""

2

3 from typing import Dict, Any, List

4 from pathlib import Path

5

6 from .schema import validate_config

7 from .loader import ConfigLoader

8

9

10 class ConfigValidator:

11 """Configuration validation utility."""

12

13 def __init__(self):

14 self.loader = ConfigLoader()

15

16 def validate_file(self, file_path: str) -> List[str]:

17 """Validate configuration file.

18

19 Args:

20 file_path: Path to configuration file

21

22 Returns:

23 List of validation errors (empty if valid)

24 """

25 errors = []

26

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

32

33 except Exception as e:

34 errors.append(str(e))

35 return errors

36

37 def validate_dict(self, config_dict: Dict[str, Any]) -> List[str]:

38 """Validate configuration dictionary.

39

40 Args:

41 config_dict: Configuration dictionary

42

43 Returns:

44 List of validation errors (empty if valid)

45 """

46 errors = []

47

48 try:

49 validate_config(config_dict)

50 return errors

51

52 except Exception as e:

53 errors.append(str(e))

54 return errors