How to validate a link against the state of a work item?

First of all, I am using RTC 4.0.6
I need to block a Defect from being associated to Work Items in a closed state. I think that this could be done with script based validation, but I didn't find a way to retrieve the other end of a link via the API. Can anyone give me a heads up on this issue and point me in the right direction?
One answer

Since you can not access links in JavaScript, it can not be done with JavaScript. The limitations of Javascript are discussed e.g. in https://jazz.net/library/article/1093 .
The only workable solution, I am aware of in this case today is an advisor. See https://rsjazz.wordpress.com/2014/05/26/only-owner-can-close-workitem-advisor/ as an example. The advisor would have to check if there is a new relationship to be created and prevent the save.
The only workable solution, I am aware of in this case today is an advisor. See https://rsjazz.wordpress.com/2014/05/26/only-owner-can-close-workitem-advisor/ as an example. The advisor would have to check if there is a new relationship to be created and prevent the save.