SDK Guide
Validation
Structural and referential integrity checks for a UPGDocument — what validateGraph catches, what it doesn't, and how to add custom rules.
validateGraph
validateGraph(document) runs structural and referential integrity checks on a UPGDocument. It catches dangling edge endpoints, deprecated type references, empty_cells with unresolvable axis references, and custom validator rules registered per entity type. Returns a list of ValidationError objects with path, message, and severity.
v0.4 adds anti-pattern evaluation on top of structural validation. Anti-patterns are graph-shape rules — three Personas pointing at the same Job with no Outcome, a Hypothesis with zero Evidence, a Metric with no Target. The intelligence barrel exports the anti-pattern catalogue; validateGraph runs them all by default and surfaces violations as severity='warning' errors.
import { validateGraph } from '@unified-product-graph/core'
const errors = validateGraph(document)
if (errors.length > 0) {
for (const err of errors) {
console.error(`[${err.severity}] ${err.path}: ${err.message}`)
}
}