How to compare values on a look up between two related objects

Hi!
I have a question to se if it's possible to compare values from the same property but on two different objects.

Example.
Lets say we have two objects.
A Document package and documents related to that package.

Document package has a lookup property to facility which is a object in M-Files.

So Document Package 123 has
Facility A
Facility B

Now we have the Document that has 
Facilty A 
Facility B

And we try to add Facility C to the Document.

When adding facility C i would like to raise an error because it should not be possible to set facilities that are not on a Document Package level.

And I would also like to raise an error on the Document Package level if a user wants to remove a facility value when there are documents that have that facility.

So I need to compare the two objects and there facility values so that they match.
Could this be done using property calculator or is this more of an vb-script solution.