@@ -37,7 +37,8 @@ def validate_config_file(file_path, schema):
3737 """Validate a single config file against the schema."""
3838 try :
3939 with open (file_path , 'r' ) as f :
40- config = yaml .safe_load (f )
40+ # Handle multi-document YAML files
41+ documents = list (yaml .safe_load_all (f ))
4142
4243 # Create a resolver that can handle references to other schema files
4344 schema_dir = Path (__file__ ).parent .resolve ()
@@ -64,9 +65,30 @@ def custom_uri_handler(uri):
6465 handlers = {'' : custom_uri_handler }
6566 )
6667
67- Draft7Validator (schema , resolver = resolver ).validate (config )
68- print (f"✓ { file_path } - Valid" )
69- return True
68+ validator = Draft7Validator (schema , resolver = resolver )
69+
70+ # Validate each document
71+ all_valid = True
72+ for i , config in enumerate (documents ):
73+ if config is None : # Skip empty documents
74+ continue
75+ try :
76+ validator .validate (config )
77+ except ValidationError as e :
78+ print (f"✗ { file_path } - Document { i + 1 } Invalid:" )
79+ print (f" Error: { e .message } " )
80+ print (f" Path: { ' -> ' .join (str (p ) for p in e .path )} " )
81+ all_valid = False
82+
83+ if all_valid :
84+ doc_count = len ([d for d in documents if d is not None ])
85+ if doc_count > 1 :
86+ print (f"✓ { file_path } - Valid ({ doc_count } documents)" )
87+ else :
88+ print (f"✓ { file_path } - Valid" )
89+ return True
90+ return False
91+
7092 except ValidationError as e :
7193 print (f"✗ { file_path } - Invalid:" )
7294 print (f" Error: { e .message } " )
0 commit comments