Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions fixtures/negative/rule-required-categories-malformed.dspack.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "https://aestheticfunction.github.io/dspack/schema/dspack.v0.4.schema.json",
"dspack": "0.4",
"name": "negative/required-categories-malformed",
"description": "requiredCategories entries are {id, min?} only: a bare string, a missing id, or min 0 must all fail schema validation.",
"version": "0.0.1",
"tokens": { "color": { "values": { "primary": { "value": "#3366ff" } } } },
"components": {
"field": { "name": "Field", "description": "A field wrapper.", "props": {}, "categories": ["form"] }
},
"categories": { "form": { "name": "Form", "description": "Form structure." } },
"intents": [ { "id": "data-entry", "name": "Data entry", "description": "Collect input." } ],
"rules": [
{
"id": "rule.malformed",
"type": "required-composition",
"severity": "must",
"component": "field",
"requiredCategories": [ { "min": 0 } ],
"rationale": "Malformed entry: no id, min below 1."
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "https://aestheticfunction.github.io/dspack/schema/dspack.v0.4.schema.json",
"dspack": "0.4",
"name": "negative/required-categories-unknown-category",
"description": "A required-composition rule referencing a category the document does not register must fail category consistency — the same class of finding forbiddenCategories produces.",
"version": "0.0.1",
"tokens": { "color": { "values": { "primary": { "value": "#3366ff" } } } },
"components": {
"field": {
"name": "Field",
"description": "A field wrapper.",
"props": {},
"categories": ["form"]
}
},
"categories": { "form": { "name": "Form", "description": "Form structure." } },
"intents": [ { "id": "data-entry", "name": "Data entry", "description": "Collect input." } ],
"rules": [
{
"id": "rule.field-carries-control",
"type": "required-composition",
"severity": "must",
"component": "field",
"requiredCategories": [ { "id": "interactve", "min": 1 } ],
"rationale": "Typo'd category id: must be reported against the registry, never silently never-matching."
}
]
}
4 changes: 4 additions & 0 deletions lib/validate.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ export function checkCategories(doc) {
}
for (const rule of doc.rules ?? []) {
checkMember(rule.id ?? "(rule without id)", rule.forbiddenCategories);
checkMember(
rule.id ?? "(rule without id)",
(rule.requiredCategories ?? []).map((r) => r.id),
);
}
Comment on lines 180 to 186
return errors;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@aestheticfunction/dspack-spec",
"version": "0.4.2",
"version": "0.4.3",
"description": "The dspack specification: spec documents, JSON Schemas, reference example contracts, and the validation harness (bin: dspack-validate).",
"type": "module",
"license": "Apache-2.0",
Expand Down
Loading
Loading