Skip to main content
Version: 4.3

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

ParameterType
contextValidateConnectionParams

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>;

Stay in the know

Be where thousands of diagramming enthusiasts meet

Star us on GitHub