How to make my validateForm working?
I figured it out!
this works:  

$values=$form_state-&gt;getValues();  
if ($values['estlecontact']['value']==1 &amp;&amp; $values['adherentid'][0]['target_id']==NULL) {  
  $form_state-&gt;setErrorByName('estlecontact', t('L\'Adhérent est obligatoire quand la Personne est désignée comme Contact.'));  
}


Note that $values['adherentid'] is a mutliple value field. I was missing an array level. Adding [0] before accesing target_id solves the problem.