$value = $form_state->getTemporaryValue('my_form_element');
if ($form_state->getTemporaryValue('my_form_element') === 'some_value') { // Perform some action }In this example, the temporary value of the form element 'my_form_element' is compared to a string 'some_value' and if they match, a certain action is performed. Package Library: Drupal\Core\Form.