Customization of Dragging tool: how to implement validation before drop?

Hi,

there is a method doDropOnto() which is called after the drop.
What is the right way to implement validation before drop and reject it if necessary?

Thank you

You should be able to cancel the tool. From Planogram:

    myDiagram.mouseDrop = function(e) {
      if (AllowTopLevel) {
        // when the selection is dropped in the diagram's background,
        // make sure the selected Parts no longer belong to any Group
        if (!e.diagram.commandHandler.addTopLevelParts(e.diagram.selection, true)) {
          e.diagram.currentTool.doCancel();
        }
      } else {
        // disallow dropping any regular nodes onto the background, but allow dropping "racks"
        if (!e.diagram.selection.all(function(p) { return p instanceof go.Group; })) {
          e.diagram.currentTool.doCancel();
        }
      }
    };

Planogram also shows how to do real-time validation, with changing the cursor:

// what to do when a drag-drop occurs in the Diagram's background
myDiagram.mouseDragOver = function(e) {
  if (!AllowTopLevel) {
    // but OK to drop a group anywhere
    if (!e.diagram.selection.all(function(p) { return p instanceof go.Group; })) {
      e.diagram.currentCursor = "not-allowed";
    }
  }
};

Thank you!