Refine use cases rule examples

This commit is contained in:
adilallo
2026-05-19 22:16:08 -06:00
parent 7c46cbd87b
commit 2f2b5d0dc2
65 changed files with 3129 additions and 252 deletions
+9 -1
View File
@@ -19,11 +19,19 @@ export function isDocumentEntry(x: unknown): x is CommunityRuleEntry {
if (typeof o.title !== "string" || o.title.trim().length === 0) {
return false;
}
if (typeof o.body !== "string") return false;
if (o.blocks !== undefined) {
if (!Array.isArray(o.blocks) || !o.blocks.every(isLabeledBlock)) {
return false;
}
}
const blocks = Array.isArray(o.blocks) ? o.blocks : [];
const hasBlocks = blocks.length > 0;
if (hasBlocks) {
if (o.body !== undefined && typeof o.body !== "string") {
return false;
}
return true;
}
if (typeof o.body !== "string") return false;
return true;
}