public function submitForm(array &$form, FormStateInterface $form_state) { $name = $form_state->cleanValues()->getValues()['name']; // Do something with the cleaned name value }This code retrieves the "name" value submitted in the form, cleans it using cleanValues, and then stores the resulting clean value in the $name variable for further processing. The Drupal core form module is the package library used here.