Change value on validate form when I create or edit a block I need change a value to element on form validation.

I have this code:

/**
 * Implements hook_form_FORM_alter().
 */
function MY_MODULE_form_alter(&amp;$form, FormStateInterface $form_state, $form_id) {
  if ($form_id == 'block_content_MY_BLOCK_form' || $form_id == 'block_content_MY_BLOCK_edit_form') {
    $form['#validate'][] = '_custom_validate';
  }
}


I want change the value of field field_test. This field is plain text.

function _custom_validate($form, FormStateInterface $form_state) {
  $form_state-&gt;setValueForElement($form['field_test'], 'changed');
}


But when I saved this block, the field field_test doesn't change its value.

What I am doing wrong?
Please insert the validate method inside the #element_validate function and then change the element value.

/**
 * Implements hook_form_FORM_alter().
 */
function MY_MODULE_form_alter(&amp;$form, FormStateInterface $form_state, $form_id) {
  if ($form_id == 'block_content_MY_BLOCK_form' ||  $form_id =='block_content_MY_BLOCK_edit_form') {
       $form['field_test']['widget'][0]['#element_validate'][] = '_custom_validate';
      }
    }

function _custom_validate(&amp;$element, FormStateInterface $form_state, &amp;$complete_form) {
  $form_state-&gt;setValueForElement($element,['value' =&gt; 'See the change']);
}