onBeforeCompleteConnection property

ConnectionValidationResult Function(ConnectionCompleteContext<T> context)? onBeforeCompleteConnection
final

Validation callback called before completing a connection to a target port.

Return a ConnectionValidationResult to control whether the connection can be created. Set allowed: false to prevent the connection.

Use this to implement custom connection rules, type checking, or prevent cycles in the graph.

Example:

onBeforeCompleteConnection: (context) {
  // Check if connection would create a cycle
  if (wouldCreateCycle(context.sourceNode, context.targetNode)) {
    return ConnectionValidationResult(
      allowed: false,
      message: 'This would create a cycle',
    );
  }
  return ConnectionValidationResult(allowed: true);
}

Implementation

final ConnectionValidationResult Function(
  ConnectionCompleteContext<T> context,
)?
onBeforeCompleteConnection;