Skip to content

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.).

Parameters

options?

TypeMatchValidatorOptions

Returns

(source, target, info): boolean

Parameters

source

NodeGraphPortRef

target

NodeGraphPortRef

info

NodeGraphConnectionValidationInfo

Returns

boolean