But if you create a link with the Gantt API (for example, with the addLink method), there are no limitations for that. So, you need to manually check if the link should be added.
Gantt calls the isLinkAllowed method before you finish creating a link from the UI. There are several conditions that Gantt checks to determine if it is a valid link:
The source task’s id is equal to the target task’s id.
If the type is set to a value that is not 0, 1, 2, or 3.
If the link failed the validation.
If the link is created from the project task to its sub-task. The dates of the project task depend on the dates of children tasks.