Skip to content

Validate a model

validateArchiModel checks the structural integrity of an already parsed model — missing/duplicate identifiers and dangling cross-references.

import { parseArchiModel, validateArchiModel } from '@cda/archi-semantic-core';
const model = parseArchiModel(xml);
const result = validateArchiModel(model);
console.log(result.valid); // boolean
for (const issue of result.errors) {
console.log(issue.code, issue.message, issue.path);
}

The validator builds one global id set spanning all seven id-bearing collections (folders, elements, relationships, views, diagram objects, diagram connections, notes — Archi draws every id, semantic and visual, from one shared pool), then checks:

CodeTriggered by
missing-idAn entry has no id at all.
duplicate-idThe same id appears on more than one entry, anywhere in the model.
broken-relationship-sourceA relationship’s sourceId doesn’t resolve to any known id.
broken-relationship-targetA relationship’s targetId doesn’t resolve to any known id.
unrecognized-junction-typeA Junction element’s native type attribute isn’t ""/absent (And) or "or" (Or).
broken-diagram-object-elementA diagram object’s archimateElementId doesn’t resolve to any known id.
broken-diagram-object-model-referenceA DiagramModelReference’s referencedModelId doesn’t resolve to any known id.
broken-diagram-connection-relationshipA connection’s archimateRelationshipId doesn’t resolve to any known id.
broken-diagram-connection-sourceA connection’s sourceId doesn’t resolve to any known id.
broken-diagram-connection-targetA connection’s targetId doesn’t resolve to any known id.

Every ArchiValidationIssue carries a path locator into the returned ArchiModel — not the original XML — so a failure can be traced straight back to the field that failed:

"relationships[rel-1].sourceId"
"diagramConnections[conn-7].targetId"

{ valid: true, errors: [] } means every id-bearing entry has a unique, non-empty id and every cross-reference this validator checks resolves. It does not check:

  • ArchiBounds completeness;
  • ArchiProfile/profiles references;
  • anything style- or feature-related.

This validator is not an enterprise-architecture quality linter. A model can be structurally valid and still represent poor architecture. Quality rules belong in a separate layer (for example, a governance tool built on top of ArchiModel), not in the semantic core. Label expressions are not evaluated by the validator either — resolution is a render-time concern, not an integrity concern.

The validator is a natural pipeline gate: run it in a pre-commit hook or a CI step and let the exit code block merges. See Structural validation in CI for a full recipe with human-readable reports.