Wordpress before Post publish or update validation

I am currently creating a wordpress plugin where the following scenario takes place:

  1. usertype1 can post a certain information with posttype1
  2. usertype2 can post a post with posttype2 which is linked to usertype1's post

what I need to do check if usertype2 doesn't have the same post with posttype2 linked on the same post with posttype1.

Any idea how this can be done? I only started working with wordpress and I don't really know how to accomplish this