Validate where untrusted data enters
A content importer receives records that authoring tools can shape differently. The importer can define the expected fields once and validate every record before choosing its route. A failed field check can be reported with the source filename, leaving the previously reviewed output intact.
Use an explicit schema
The pure entry works without global string extensions. In schema-dsl@3.0.5, this rule requires a 3–80 character title and one of two languages, en or zh-CN. The trailing ! makes each field required.
import { s, validate } from 'schema-dsl/pure';
const page = s({ title: s('string:3-80!'), language: 'en|zh-CN!' });
const records = [
{ title: 'Project guide', language: 'en' },
{ title: 'Project guide' },
{ title: 'Project guide', language: 'fr' },
{ title: '', language: 'zh-CN' },
];
console.log(records.map(record => validate(page, record).valid));
// [true, false, false, false]
The four rows produced [true, false, false, false] in a local check with 3.0.5. With the optional enum en|zh-CN, the row without a language passed.
Cross-record checks live above the schema
A valid record can still conflict with another valid record. Suppose an importer lowercases route slugs. If content/Guide.en.md and content/guide.en.md both map to /blog/guide/, report both source paths and the conflicting URL. Check the full inventory for route collisions, duplicate IDs and missing translation targets before replacing the previous output.