ValidateConnection
type ValidateConnection = (context) => boolean;
Decides whether a link may connect its source end to its target end. Return
true to allow the connection, false to reject it. Pass it (or a
CanConnectOptions object) to the validateConnection prop of <Paper>;
the callback receives a structured ValidateConnectionParams context.
Parameters
| Parameter | Type |
|---|---|
context | ValidateConnectionParams |
Returns
boolean
Example
import { GraphProvider, Paper } from '@joint/react';
import type { ValidateConnection } from '@joint/react';
// Only accept links that end on a port named "in".
const validate: ValidateConnection = ({ target }) => target.port === 'in';
<GraphProvider>
<Paper validateConnection={validate} renderElement={() => <rect width={80} height={40} />} />
</GraphProvider>;