package file→ .shtukbase/packages/content/checks/c03_length.ts
checks/c03_length.ts
20 lines, 1.2 KB.
- // CNT-R03 (the measurable part). The body of an approved or published draft (characters with spaces, without the
- // head, trimmed) is within minChars..maxChars of its platform. Style, tone and format are the judge's part.
- import { FOLDERS, exists, page, phase, records, ref, report } from '../lib/content.ts';
- const out: string[] = [];
- let n = 0;
- for (const r of records(FOLDERS.drafts)) {
- if (!['approved', 'published'].includes(phase(r.fm.status))) continue;
- const pl = ref(r.fm.platform, r.id);
- if (!pl || !exists(pl)) continue; // CNT-R02 says it
- n++;
- const fm = page(pl).fm;
- const max = typeof fm.maxChars === 'number' ? fm.maxChars : null;
- const min = typeof fm.minChars === 'number' ? fm.minChars : 0;
- const len = [...r.body.trim()].length;
- if (max === null) out.push(`${r.id}: platform ${pl} has no maxChars → write a length limit on the platform [no-limit]`);
- else if (len > max) out.push(`${r.id}: ${len} characters, but platform ${pl} takes up to ${max} → shorten the text and return to review [too-long]`);
- if (len < min) out.push(`${r.id}: ${len} characters, but platform ${pl} needs at least ${min} → extend the text and return to review [too-short]`);
- }
- report(out, `approved drafts (${n})`);