Repository navigation
feat: validate content collections at build time (#156) - #173
truthixify merged 7 commits into
Conversation
Add scripts/validate-content.ts — a zero-dep TypeScript build step that validates every JSON content collection before tsc runs. Collections covered: - case-studies.json (required fields, ISO date, status enum, dup id/slug) - authors.json (required fields, optIn boolean, optional link URLs) - contributors.json (required fields, avatar/profile URLs, dup username) - faq.json (required fields, category cross-ref, dup id) - chains.json (required fields, numeric fields, docs URL, dup id) - wave.json (currentWave + pastWaves + faq, applyUrl, ISO dates) - ecosystem.json (required fields, link URL, category cross-ref) - roadmap.json (required fields, status enum, dup milestone id) - blog-posts.json (required fields, publishedAt ISO, url, dup slug) - src/i18n/ (all locales match en.json leaf-key shape) On failure: prints source file + record identifier for every violation, then exits 1 to abort the build. Wiring: - Prepended to the `build` script so TypeScript compile never runs on broken data. - New `validate:content` standalone script for local checks. - Explicit CI step in ci.yml between lint:i18n and test:a11y.
|
@aristotle224 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
@aristotle224 is attempting to deploy a commit to the truthixify's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
The validator only checks a hardcoded file list, so any new JSON collection silently bypasses the gate. Please discover every src/data JSON file and fail when one has no schema. Also validate ISO dates strictly because new Date('1') currently passes. |
- Replace hardcoded VALIDATORS array with SCHEMA_MAP + readdirSync so any
new *.json file in src/data/ that lacks a registered validator fails the
build immediately instead of silently bypassing the gate.
- Fix isIsoDate to use a strict ISO 8601 regex instead of a bare new Date()
call. Rejects previously-passing inputs like '1', '2026-1-5', 'August 14'.
Accepts YYYY-MM-DD and YYYY-MM-DDTHH:mm:ss[.sss](Z|+/-HH:mm).
- Add validators for the 9 previously-uncovered collections:
trust, showcase, incidents, security, blog-manifest,
authors-optout, contributors-optout, team, threat-model.
- Fix data bug caught by the new gate: team.json contributors[0].github
was a bare username ('code3ks') rather than a full URL.
Also format Newsletter.tsx, stellarMetrics.ts, track.ts (pre-existing
Prettier drift, caught by the pre-commit hook).
Closes wraith-protocol#156
…compliant The generator was writing JSON.stringify(..., null, 2) with no trailing newline. Prettier requires one, causing format:check to fail on every build because gen-blog-manifest runs after Prettier in the pre-commit hook.
Done, please review |
|
Dynamic discovery is fixed. The date regex still accepts impossible dates such as 2026-02-31. Please validate that the parsed year, month, and day are real, and add coverage for this case. |
Extract isIsoDate into src/utils/date.ts and add a calendar roll-over check after the regex: construct a local Date from the parsed year/month/day and verify none of the values changed due to JS Date normalisation. Update scripts/validate-content.ts to import from the new utility. Add 30 tests in src/__tests__/date.test.ts covering valid dates, impossible calendar dates (Feb 29/30/31, Apr/Jun/ Sep/Nov 31, century non-leap years), and structural rejections.
5a2697c to
39f4045
Compare
Done, Please review |
|
The calendar validation is fixed. One blocker remains: |
eb0e689 to
86e524e
Compare
truthixify
left a comment
There was a problem hiding this comment.
Content validation now covers every collection, rejects invalid dates, and runs in the production build. Looks good.
|
Merged. Content collections are now validated in CI and production builds. Thanks @aristotle224. |
Closes #156
Summary
Adds
scripts/validate-content.ts— a zero-dependency TypeScript scriptthat validates every JSON content collection before
tscruns, failingthe build immediately on bad data.
What's validated
case-studies.jsonauthors.jsoncontributors.jsonfaq.jsonchains.jsonwave.jsonecosystem.jsonroadmap.jsonblog-posts.jsonsrc/i18n/Error output format
src/data/case-studies.json [entries[1] id="bad-entry"]
→ field "integrationDate" must be a valid ISO date string (got "not-a-date")
Wiring
pnpm build— TypeScript compile never runs on brokendata
pnpm validate:contentstandalone script for local checksci.ymlbetweenlint:i18nandtest:a11yTesting
pnpm buildpasses (verified by pre-commit hook)invalid date, missing field, and invalid enum all reported correctly