Skip to content

Commit 7727b25

Browse files
committed
subdoc parsing
1 parent a0e2308 commit 7727b25

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

.github/scripts/validate-and-merge.mjs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,9 @@ async function validateAndMerge() {
6262
const yamlDocuments = yaml.loadAll(content);
6363

6464
for (const document of yamlDocuments) {
65-
const isValid = requiredKeys.every(key => key in document);
66-
65+
const isValid = validateSubdocument(document);
6766
if (!isValid) {
68-
console.log(JSON.parse(document) + ' is missing required keys');
69-
return;
70-
}
71-
72-
if (!Array.isArray(document.categories) || document.categories.length === 0) {
73-
console.log('Categories must be a non-empty array');
67+
console.log(`Invalid subdocument: ${JSON.stringify(document)}`);
7468
return;
7569
}
7670
}
@@ -88,4 +82,20 @@ async function validateAndMerge() {
8882
}
8983
}
9084

85+
function validateSubdocument(subdocument) {
86+
const isValid = requiredKeys.every(key => key in subdocument);
87+
88+
if (!isValid) {
89+
console.log(`Subdocument is missing required keys: ${JSON.stringify(subdocument)}`);
90+
return false;
91+
}
92+
93+
if (!Array.isArray(subdocument.categories) || subdocument.categories.length === 0) {
94+
console.log('Categories must be a non-empty array');
95+
return false;
96+
}
97+
98+
return true;
99+
}
100+
91101
validateAndMerge();

0 commit comments

Comments
 (0)