Remove required field in validation form
Use states to style the input as required. This won't actually perform any validation but will add the required asterisk to the field when field B has a certain value.

$form['FIELD_A']['#states'] = [
  'required' =&gt; array(
    ':input[name="FIELD_B"]' =&gt; array('value' =&gt; 'foo'),
  ),
];


Then use custom validation to actually check FIELD_A has the correct value depending on the value of FIELD_B.