Skip to content
Entangle UI v0.13.0

createTypeMatchValidator

createTypeMatchValidator(options?): (source, target, info) => boolean

Defined in: src/components/editor/NodeGraph/createTypeMatchValidator.ts:47

Build an isValidConnection validator for the common “connect ports of matching dataType, in an allowed direction” rule — the logic most node editors hand-write. Drop the result straight onto <NodeGraph>:

const isValidConnection = useMemo(() => createTypeMatchValidator(), []);
<NodeGraph isValidConnection={isValidConnection} />

The default match accepts a connection when either port is untyped, the two dataTypes are equal, or one side is the anyType token. Override match for richer rules (subtype graphs, numeric coercion, etc.).

TypeMatchValidatorOptions

(source, target, info) => boolean