Skip to content

@graphty/graphty-element / extend / checkShapeContract

Function: checkShapeContract() ​

checkShapeContract(shape, fields): readonly ShapeContractViolation[]

Defined in: graphty-element/src/session/results/types.ts:557

Check one algorithm's declared fields against the contract its shape publishes.

This is the machine-checkable half of "uniform field names": a shape is only worth having if something fails when an algorithm skips a field it promised, and that is this function. It reads a field list -- a catalogue descriptor's fields, or a finished RunResult.fields -- and never the values behind it.

Parameters ​

shape ​

"node-metric" | "edge-metric" | "community" | "layered-grouping" | "category-table" | "path" | "node-set" | "edge-set" | "pair-list" | "temporal" | "fact"

The shape the result claims.

fields ​

readonly FieldDescriptor[]

The fields it declares.

Returns ​

readonly ShapeContractViolation[]

Every violation, in declaration order; empty when the contract is kept.