$form_state->setValue('first_name', $first_name);
$form_state->setErrorByName('field_name', t('Error message.'));
$form_state->setRedirectUrl($url_object);This code sets a redirect URL for the form submission. The $url_object variable contains the URL object with the redirect URL. These examples use the drupal/core library, specifically the FormStateInterface class, which is used for handling the state of a Drupal form.