How can I get the content type name inside the hook_form_BASE_FORM_ID_alter() hook? I need to obtain the content type name inside an implementation of the hook_form_BASE_FORM_ID_alter() hook for the node edit/add form to made some validations.

I can't find any node object reference using kint() to access to the $node-&gt;getType() value.

I need to do a validation like this:

if ($node-&gt;getType() == 'article') {
...
}


So, how can I get the content type name inside the hook_form_BASE_FORM_ID_alter() hook?
You can get the node from the form object.

use Drupal\Core\Form\FormStateInterface;

/**
 * Implements hook_form_BASE_FORM_ID_alter().
 */
function yourmodule_form_node_form_alter(&amp;$form, FormStateInterface $form_state, $form_id) {
  /* @var \Drupal\node\NodeInterface $node */
  $node = $form_state-&gt;getFormObject()-&gt;getEntity();

  if (!$node-&gt;getType() == 'article') {
    // ....
  }
}


Note that getEntity() doesn't exist on \Drupal\Core\Form\FormInterface, which is why it doesn't show up as a method in an IDE. It only exists on \Drupal\Core\Entity\EntityFormInterface, you can add an explicit instance of for that.