ShtukbaseStandard
package file→ .shtukbase/packages/content/checks/c03_length.ts

checks/c03_length.ts

20 lines, 1.2 KB.

  1. // CNT-R03 (the measurable part). The body of an approved or published draft (characters with spaces, without the
  2. // head, trimmed) is within minChars..maxChars of its platform. Style, tone and format are the judge's part.
  3. import { FOLDERS, exists, page, phase, records, ref, report } from '../lib/content.ts';
  4. const out: string[] = [];
  5. let n = 0;
  6. for (const r of records(FOLDERS.drafts)) {
  7. if (!['approved', 'published'].includes(phase(r.fm.status))) continue;
  8. const pl = ref(r.fm.platform, r.id);
  9. if (!pl || !exists(pl)) continue; // CNT-R02 says it
  10. n++;
  11. const fm = page(pl).fm;
  12. const max = typeof fm.maxChars === 'number' ? fm.maxChars : null;
  13. const min = typeof fm.minChars === 'number' ? fm.minChars : 0;
  14. const len = [...r.body.trim()].length;
  15. if (max === null) out.push(`${r.id}: platform ${pl} has no maxChars → write a length limit on the platform [no-limit]`);
  16. 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]`);
  17. 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]`);
  18. }
  19. report(out, `approved drafts (${n})`);