How to make the comment author name required for anonymous users? I'm trying to make the comment author name required with this code:

use Drupal\Core\Form\FormStateInterface;
/**
 * Implements hook_form_FORM_ID_alter().
 */
function MODULE_form_comment_comment_form_alter(array &amp;$form, FormStateInterface $form_state, $form_id) {
  $form['name']['#required'] = true;
}


But I can't find the way to do so. How to make the comment author name required for anonymous users?
I found the answer:

Implementing the hook_form_FORM_ID_alter() hook you can use the comment form id (comment_comment_form) to alter the form.

The problem was that the field name is inside the author, so you need to use $form['author']['name']['#required'] = TRUE;

/**
 * Implements hook_form_FORM_ID_alter().
 */
function MODULE_form_comment_comment_form_alter(array &amp;$form, FormStateInterface $form_state, $form_id) {
  $form['author']['name']['#required'] = TRUE;
}