diff --git a/core/modules/action/src/Plugin/Action/EmailAction.php b/core/modules/action/src/Plugin/Action/EmailAction.php
index 1c67123..58409d1 100644
--- a/core/modules/action/src/Plugin/Action/EmailAction.php
+++ b/core/modules/action/src/Plugin/Action/EmailAction.php
@@ -159,7 +159,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
   public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
     if (!valid_email_address($form_state->getValue('recipient')) && strpos($form_state->getValue('recipient'), ':mail') === FALSE) {
       // We want the literal %author placeholder to be emphasized in the error message.
-      form_set_error('recipient', $form_state, t('Enter a valid email address or use a token email address such as %author.', array('%author' => '[node:author:mail]')));
+      $form_state->setErrorByName('recipient', t('Enter a valid email address or use a token email address such as %author.', array('%author' => '[node:author:mail]')));
     }
   }
 
diff --git a/core/modules/color/color.module b/core/modules/color/color.module
index a06ab8e..943c61f 100644
--- a/core/modules/color/color.module
+++ b/core/modules/color/color.module
@@ -334,7 +334,7 @@ function color_scheme_form_validate($form, FormStateInterface $form_state) {
   // Only accept hexadecimal CSS color strings to avoid XSS upon use.
   foreach ($form_state->getValue('palette') as $key => $color) {
     if (!color_valid_hexadecimal_string($color)) {
-      form_set_error('palette][' . $key, $form_state, t('You must enter a valid hexadecimal color value for %name.', array('%name' => $form['color']['palette'][$key]['#title'])));
+      $form_state->setErrorByName('palette][' . $key, t('You must enter a valid hexadecimal color value for %name.', array('%name' => $form['color']['palette'][$key]['#title'])));
     }
   }
 }
diff --git a/core/modules/content_translation/content_translation.admin.inc b/core/modules/content_translation/content_translation.admin.inc
index 6620477..d9c1850 100644
--- a/core/modules/content_translation/content_translation.admin.inc
+++ b/core/modules/content_translation/content_translation.admin.inc
@@ -265,7 +265,7 @@ function content_translation_form_language_content_settings_validate(array $form
         $translatable_fields = isset($settings[$entity_type][$bundle]['fields']) ? array_filter($settings[$entity_type][$bundle]['fields']) : FALSE;
         if (empty($translatable_fields)) {
           $t_args = array('%bundle' => $form['settings'][$entity_type][$bundle]['settings']['#label']);
-          form_set_error($name, $form_state, t('At least one field needs to be translatable to enable %bundle for translation.', $t_args));
+          $form_state->setErrorByName($name, t('At least one field needs to be translatable to enable %bundle for translation.', $t_args));
         }
 
         $values = $bundle_settings['settings']['language'];
@@ -273,7 +273,7 @@ function content_translation_form_language_content_settings_validate(array $form
           foreach (\Drupal::languageManager()->getLanguages(LanguageInterface::STATE_LOCKED) as $language) {
             $locked_languages[] = $language->name;
           }
-          form_set_error($name, $form_state, t('Translation is not supported if language is always one of: @locked_languages', array('@locked_languages' => implode(', ', $locked_languages))));
+          $form_state->setErrorByName($name, t('Translation is not supported if language is always one of: @locked_languages', array('@locked_languages' => implode(', ', $locked_languages))));
         }
       }
     }
diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module
index 5ca5e2e..357d36b 100644
--- a/core/modules/content_translation/content_translation.module
+++ b/core/modules/content_translation/content_translation.module
@@ -783,7 +783,7 @@ function content_translation_language_configuration_element_validate($element, F
     // @todo Set the correct form element name as soon as the element parents
     //   are correctly set. We should be using NestedArray::getValue() but for
     //   now we cannot.
-    form_set_error('', $form_state, t('"Show language selector" is not compatible with translating content that has default language: %choice. Either do not hide the language selector or pick a specific language.', array('%choice' => $locked_languages[$values['langcode']])));
+    $form_state->setErrorByName('', t('"Show language selector" is not compatible with translating content that has default language: %choice. Either do not hide the language selector or pick a specific language.', array('%choice' => $locked_languages[$values['langcode']])));
   }
 }
 
diff --git a/core/modules/content_translation/src/ContentTranslationHandler.php b/core/modules/content_translation/src/ContentTranslationHandler.php
index 734ee5d..30acf2d 100644
--- a/core/modules/content_translation/src/ContentTranslationHandler.php
+++ b/core/modules/content_translation/src/ContentTranslationHandler.php
@@ -416,11 +416,11 @@ function entityFormValidate($form, FormStateInterface $form_state) {
       $translation = $form_state->getValue('content_translation');
       // Validate the "authored by" field.
       if (!empty($translation['name']) && !($account = user_load_by_name($translation['name']))) {
-        form_set_error('content_translation][name', $form_state, t('The translation authoring username %name does not exist.', array('%name' => $translation['name'])));
+        $form_state->setErrorByName('content_translation][name', t('The translation authoring username %name does not exist.', array('%name' => $translation['name'])));
       }
       // Validate the "authored on" field.
       if (!empty($translation['created']) && strtotime($translation['created']) === FALSE) {
-        form_set_error('content_translation][created', $form_state, t('You have to specify a valid translation authoring date.'));
+        $form_state->setErrorByName('content_translation][created', t('You have to specify a valid translation authoring date.'));
       }
     }
   }
diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module
index 3e2804d..ce3b9fa 100644
--- a/core/modules/editor/editor.module
+++ b/core/modules/editor/editor.module
@@ -207,7 +207,7 @@ function editor_form_filter_admin_format_validate($form, FormStateInterface $for
   // selected a text editor and has then clicked 'Save configuration', we should
   // point out that the user must still configure the text editor.
   if ($form_state->getValue(array('editor', 'editor')) !== '' && empty($form_state['editor'])) {
-    form_set_error('editor][editor', $form_state, t('You must configure the selected text editor.'));
+    $form_state->setErrorByName('editor][editor', t('You must configure the selected text editor.'));
   }
 }
 
diff --git a/core/modules/file/file.module b/core/modules/file/file.module
index 825594e..af6ccab 100644
--- a/core/modules/file/file.module
+++ b/core/modules/file/file.module
@@ -1446,7 +1446,7 @@ function file_managed_file_save_upload($element, FormStateInterface $form_state)
   $destination = isset($element['#upload_location']) ? $element['#upload_location'] : NULL;
   if (isset($destination) && !file_prepare_directory($destination, FILE_CREATE_DIRECTORY)) {
     \Drupal::logger('file')->notice('The upload directory %directory for the file field !name could not be created or is not accessible. A newly uploaded file could not be saved in this directory as a consequence, and the upload was canceled.', array('%directory' => $destination, '!name' => $element['#field_name']));
-    form_set_error($upload_name, $form_state, t('The file could not be uploaded.'));
+    $form_state->setErrorByName($upload_name, t('The file could not be uploaded.'));
     return FALSE;
   }
 
@@ -1456,7 +1456,7 @@ function file_managed_file_save_upload($element, FormStateInterface $form_state)
   if ($files_uploaded) {
     if (!$files = file_save_upload($upload_name, $element['#upload_validators'], $destination)) {
       \Drupal::logger('file')->notice('The file upload failed. %upload', array('%upload' => $upload_name));
-      form_set_error($upload_name, $form_state, t('Files in the !name field were unable to be uploaded.', array('!name' => $element['#title'])));
+      $form_state->setErrorByName($upload_name, t('Files in the !name field were unable to be uploaded.', array('!name' => $element['#title'])));
       return array();
     }
 
diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module
index d30c85b..ed2f05a 100644
--- a/core/modules/forum/forum.module
+++ b/core/modules/forum/forum.module
@@ -213,7 +213,7 @@ function forum_node_validate(EntityInterface $node, $form, FormStateInterface $f
         }
         $term = $item->entity;
         if (!$term) {
-          form_set_error('taxonomy_forums', $form_state, t('Select a forum.'));
+          $form_state->setErrorByName('taxonomy_forums', t('Select a forum.'));
           continue;
         }
         $used = \Drupal::entityQuery('taxonomy_term')
@@ -223,7 +223,7 @@ function forum_node_validate(EntityInterface $node, $form, FormStateInterface $f
           ->count()
           ->execute();
         if ($used && !empty($term->forum_container->value)) {
-          form_set_error('taxonomy_forums', $form_state, t('The item %forum is a forum container, not a forum. Select one of the forums below instead.', array('%forum' => $term->getName())));
+          $form_state->setErrorByName('taxonomy_forums', t('The item %forum is a forum container, not a forum. Select one of the forums below instead.', array('%forum' => $term->getName())));
         }
       }
     }
diff --git a/core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php
index e0cb8de..e23e51a 100644
--- a/core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php
+++ b/core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php
@@ -129,7 +129,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
    */
   public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
     if (!$form_state->isValueEmpty('bgcolor') && !Color::validateHex($form_state->getValue('bgcolor'))) {
-      form_set_error('bgcolor', $form_state, $this->t('Background color must be a hexadecimal color value.'));
+      $form_state->setErrorByName('bgcolor', $this->t('Background color must be a hexadecimal color value.'));
     }
   }
 
diff --git a/core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php b/core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php
index 338be49..0b9bece 100644
--- a/core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php
+++ b/core/modules/image/src/Plugin/ImageEffect/ScaleImageEffect.php
@@ -86,7 +86,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
   public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
     parent::validateConfigurationForm($form, $form_state);
     if ($form_state->isValueEmpty('width') && $form_state->isValueEmpty('height')) {
-      form_set_error('data', $form_state, $this->t('Width and height can not both be blank.'));
+      $form_state->setErrorByName('data', $this->t('Width and height can not both be blank.'));
     }
   }
 
diff --git a/core/modules/menu_ui/menu_ui.module b/core/modules/menu_ui/menu_ui.module
index 83528b5..20c5100 100644
--- a/core/modules/menu_ui/menu_ui.module
+++ b/core/modules/menu_ui/menu_ui.module
@@ -501,7 +501,7 @@ function menu_ui_form_node_type_form_validate(&$form, FormStateInterface $form_s
   if (count($available_menus)) {
     $menu_item_id_parts = explode(':', $form_state->getValue('menu_parent'));
     if (!in_array($menu_item_id_parts[0], $available_menus)) {
-      form_set_error('menu_parent', $form_state, t('The selected menu item is not under one of the selected menus.'));
+      $form_state->setErrorByName('menu_parent', t('The selected menu item is not under one of the selected menus.'));
     }
   }
   else {
diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php
index 7f3c8f6..1a5d929 100644
--- a/core/modules/node/node.api.php
+++ b/core/modules/node/node.api.php
@@ -408,7 +408,7 @@ function hook_node_update_index(\Drupal\node\NodeInterface $node, $langcode) {
  * finished editing the node and is previewing or submitting it. It is invoked
  * at the end of all the standard validation steps.
  *
- * To indicate a validation error, use form_set_error().
+ * To indicate a validation error, use $form_state->setErrorByName().
  *
  * Note: Changes made to the $node object within your hook implementation will
  * have no effect.  The preferred method to change a node's content is to use
@@ -427,7 +427,7 @@ function hook_node_update_index(\Drupal\node\NodeInterface $node, $langcode) {
 function hook_node_validate(\Drupal\node\NodeInterface $node, $form, \Drupal\Core\Form\FormStateInterface $form_state) {
   if (isset($node->end) && isset($node->start)) {
     if ($node->start > $node->end) {
-      form_set_error('time', $form_state, t('An event may not end before it starts.'));
+      $form_state->setErrorByName('time', t('An event may not end before it starts.'));
     }
   }
 }
diff --git a/core/modules/node/src/Plugin/Action/AssignOwnerNode.php b/core/modules/node/src/Plugin/Action/AssignOwnerNode.php
index c80f7c6..8c43d4e 100644
--- a/core/modules/node/src/Plugin/Action/AssignOwnerNode.php
+++ b/core/modules/node/src/Plugin/Action/AssignOwnerNode.php
@@ -121,7 +121,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
   public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
     $exists = (bool) $this->connection->queryRange('SELECT 1 FROM {users} WHERE name = :name', 0, 1, array(':name' => $form_state->getValue('owner_name')))->fetchField();
     if (!$exists) {
-      form_set_error('owner_name', $form_state, t('Enter a valid username.'));
+      $form_state->setErrorByName('owner_name', t('Enter a valid username.'));
     }
   }
 
diff --git a/core/modules/rest/src/Plugin/views/row/DataFieldRow.php b/core/modules/rest/src/Plugin/views/row/DataFieldRow.php
index 821ed48..6f6a629 100644
--- a/core/modules/rest/src/Plugin/views/row/DataFieldRow.php
+++ b/core/modules/rest/src/Plugin/views/row/DataFieldRow.php
@@ -128,7 +128,7 @@ public function validateOptionsForm(&$form, FormStateInterface $form_state) {
     // If array filter returns empty, no values have been entered. Unique keys
     // should only be validated if we have some.
     if (($filtered = array_filter($aliases)) && (array_unique($filtered) !== $filtered)) {
-      form_set_error('aliases', $form_state, t('All field aliases must be unique'));
+      $form_state->setErrorByName('aliases', t('All field aliases must be unique'));
     }
   }
 
diff --git a/core/modules/search/src/Plugin/views/filter/Search.php b/core/modules/search/src/Plugin/views/filter/Search.php
index 20d60b6..7635125 100644
--- a/core/modules/search/src/Plugin/views/filter/Search.php
+++ b/core/modules/search/src/Plugin/views/filter/Search.php
@@ -108,7 +108,7 @@ public function validateExposed(&$form, FormStateInterface $form_state) {
     if (!$form_state->isValueEmpty($key)) {
       $this->queryParseSearchExpression($form_state->getValue($key));
       if (count($this->searchQuery->words()) == 0) {
-        form_set_error($key, $form_state, format_plural(\Drupal::config('search.settings')->get('index.minimum_word_size'), 'You must include at least one positive keyword with 1 character or more.', 'You must include at least one positive keyword with @count characters or more.'));
+        $form_state->setErrorByName($key, format_plural(\Drupal::config('search.settings')->get('index.minimum_word_size'), 'You must include at least one positive keyword with 1 character or more.', 'You must include at least one positive keyword with @count characters or more.'));
       }
     }
   }
diff --git a/core/modules/system/src/Plugin/views/field/BulkForm.php b/core/modules/system/src/Plugin/views/field/BulkForm.php
index 130dc33..bae235d 100644
--- a/core/modules/system/src/Plugin/views/field/BulkForm.php
+++ b/core/modules/system/src/Plugin/views/field/BulkForm.php
@@ -294,7 +294,7 @@ protected function emptySelectedMessage() {
   public function viewsFormValidate(&$form, FormStateInterface $form_state) {
     $selected = array_filter($form_state->getValue($this->options['id']));
     if (empty($selected)) {
-      form_set_error('', $form_state, $this->emptySelectedMessage());
+      $form_state->setErrorByName('', $this->emptySelectedMessage());
     }
   }
 
diff --git a/core/modules/system/system.module b/core/modules/system/system.module
index cad83e5..f933f57 100644
--- a/core/modules/system/system.module
+++ b/core/modules/system/system.module
@@ -8,6 +8,7 @@
 use Drupal\Core\Cache\Cache;
 use Drupal\Core\Extension\Extension;
 use Drupal\Core\Extension\ExtensionDiscovery;
+use Drupal\Core\Form\FormState;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\Core\Routing\RouteMatchInterface;
 use Drupal\Core\StringTranslation\TranslationWrapper;
@@ -1120,16 +1121,17 @@ function system_check_directory($form_element) {
     return $form_element;
   }
 
+  $form_state = new FormState();
   $logger = \Drupal::logger('file system');
   if (!is_dir($directory) && !drupal_mkdir($directory, NULL, TRUE)) {
     // If the directory does not exists and cannot be created.
-    form_set_error($form_element['#parents'][0], $form_state, t('The directory %directory does not exist and could not be created.', array('%directory' => $directory)));
+    $form_state->setErrorByName($form_element['#parents'][0], t('The directory %directory does not exist and could not be created.', array('%directory' => $directory)));
     $logger->error('The directory %directory does not exist and could not be created.', array('%directory' => $directory));
   }
 
   if (is_dir($directory) && !is_writable($directory) && !drupal_chmod($directory)) {
     // If the directory is not writable and cannot be made so.
-    form_set_error($form_element['#parents'][0], $form_state, t('The directory %directory exists but is not writable and could not be made writable.', array('%directory' => $directory)));
+    $form_state->setErrorByName($form_element['#parents'][0], t('The directory %directory exists but is not writable and could not be made writable.', array('%directory' => $directory)));
     $logger->error('The directory %directory exists but is not writable and could not be made writable.', array('%directory' => $directory));
   }
   elseif (is_dir($directory)) {
diff --git a/core/modules/system/tests/modules/form_test/src/Callbacks.php b/core/modules/system/tests/modules/form_test/src/Callbacks.php
index bababe6..ed26dd9 100644
--- a/core/modules/system/tests/modules/form_test/src/Callbacks.php
+++ b/core/modules/system/tests/modules/form_test/src/Callbacks.php
@@ -46,7 +46,7 @@ public function validateName(&$element, FormStateInterface $form_state) {
       drupal_set_message(t('@label value: @value', array('@label' => $element['#title'], '@value' => $form_state->getValue('name'))));
 
       // Trigger a form validation error to see our changes.
-      form_set_error('', $form_state);
+      $form_state->setErrorByName('');
     }
   }
 
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php
index d782ef5..f7d6150 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestProgrammaticForm.php
@@ -90,7 +90,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
    */
   public function validateForm(array &$form, FormStateInterface $form_state) {
     if ($form_state->isValueEmpty('textfield')) {
-      form_set_error('textfield', $form_state, t('Textfield is required.'));
+      $form_state->setErrorByName('textfield', t('Textfield is required.'));
     }
   }
 
diff --git a/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateForm.php b/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateForm.php
index 27f31ed..d9293b4 100644
--- a/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateForm.php
+++ b/core/modules/system/tests/modules/form_test/src/Form/FormTestValidateForm.php
@@ -69,7 +69,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) {
       drupal_set_message(t('@label value: @value', array('@label' => $form['name']['#title'], '@value' => $form_state->getValue('name'))));
 
       // Trigger a form validation error to see our changes.
-      form_set_error('', $form_state);
+      $form_state->setErrorByName('');
     }
   }
 
diff --git a/core/modules/user/user.module b/core/modules/user/user.module
index c5c8ddc..10e0066 100644
--- a/core/modules/user/user.module
+++ b/core/modules/user/user.module
@@ -507,8 +507,8 @@ function user_validate_current_pass(&$form, FormStateInterface $form_state) {
     if ((strlen(trim($form_state->getValue($key))) > 0) && ($form_state->getValue($key) != $current_value)) {
       $current_pass_failed = $form_state->isValueEmpty('current_pass') || !\Drupal::service('password')->check($form_state->getValue('current_pass'), $account);
       if ($current_pass_failed) {
-        form_set_error('current_pass', $form_state, t("Your current password is missing or incorrect; it's required to change the %name.", array('%name' => $name)));
-        form_set_error($key, $form_state);
+        $form_state->setErrorByName('current_pass', t("Your current password is missing or incorrect; it's required to change the %name.", array('%name' => $name)));
+        $form_state->setErrorByName($key);
       }
       // We only need to check the password once.
       break;
diff --git a/core/modules/views/src/Plugin/views/filter/BooleanOperator.php b/core/modules/views/src/Plugin/views/filter/BooleanOperator.php
index c635eb6..3db2233 100644
--- a/core/modules/views/src/Plugin/views/filter/BooleanOperator.php
+++ b/core/modules/views/src/Plugin/views/filter/BooleanOperator.php
@@ -165,7 +165,7 @@ protected function valueForm(&$form, FormStateInterface $form_state) {
 
   protected function valueValidate($form, FormStateInterface $form_state) {
     if ($form_state->getValue(array('options', 'value')) == 'All' && !$form_state->isValueEmpty(array('options', 'expose', 'required'))) {
-      form_set_error('value', $form_state, t('You must select a value unless this is an non-required exposed filter.'));
+      $form_state->setErrorByName('value', t('You must select a value unless this is an non-required exposed filter.'));
     }
   }
 
diff --git a/core/modules/views/src/Plugin/views/filter/Combine.php b/core/modules/views/src/Plugin/views/filter/Combine.php
index 12e6f22..7751027 100644
--- a/core/modules/views/src/Plugin/views/filter/Combine.php
+++ b/core/modules/views/src/Plugin/views/filter/Combine.php
@@ -51,7 +51,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) {
         );
       }
       else {
-        form_set_error('', $form_state, t('You have to add some fields to be able to use this filter.'));
+        $form_state->setErrorByName('', t('You have to add some fields to be able to use this filter.'));
       }
     }
   }
diff --git a/core/modules/views/src/Plugin/views/pager/SqlBase.php b/core/modules/views/src/Plugin/views/pager/SqlBase.php
index 1fe68bc..8a4a8e5 100644
--- a/core/modules/views/src/Plugin/views/pager/SqlBase.php
+++ b/core/modules/views/src/Plugin/views/pager/SqlBase.php
@@ -197,14 +197,14 @@ public function validateOptionsForm(&$form, FormStateInterface $form_state) {
       $error = TRUE;
     }
     if ($error) {
-      form_set_error('pager_options][expose][items_per_page_options', $form_state, t('Insert a list of integer numeric values separated by commas: e.g: 10, 20, 50, 100'));
+      $form_state->setErrorByName('pager_options][expose][items_per_page_options', t('Insert a list of integer numeric values separated by commas: e.g: 10, 20, 50, 100'));
     }
 
     // Make sure that the items_per_page is part of the expose settings.
     if (!$form_state->isValueEmpty(array('pager_options', 'expose', 'items_per_page')) && !$form_state->isValueEmpty(array('pager_options', 'items_per_page'))) {
       $items_per_page = $form_state->getValue(array('pager_options', 'items_per_page'));
       if (array_search($items_per_page, $options) === FALSE) {
-        form_set_error('pager_options][expose][items_per_page_options', $form_state, t("The <em>Exposed items per page</em> field's options must include the value from the <em>Items per page</em> field (@items_per_page).",
+        $form_state->setErrorByName('pager_options][expose][items_per_page_options', t("The <em>Exposed items per page</em> field's options must include the value from the <em>Items per page</em> field (@items_per_page).",
           array('@items_per_page' => $items_per_page))
         );
       }
@@ -371,7 +371,7 @@ public function exposedFormAlter(&$form, FormStateInterface $form_state) {
   public function exposedFormValidate(&$form, FormStateInterface $form_state) {
     if (!$form_state->isValueEmpty('offset') && trim($form_state->getValue('offset'))) {
       if (!is_numeric($form_state->getValue('offset')) || $form_state->getValue('offset') < 0) {
-        form_set_error('offset', $form_state, t('Offset must be an number greather or equal than 0.'));
+        $form_state->setErrorByName('offset', t('Offset must be an number greather or equal than 0.'));
       }
     }
   }
