diff --git a/core/modules/file/src/Plugin/Field/FieldType/FileItem.php b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php
index 6677db2..e89d30b 100644
--- a/core/modules/file/src/Plugin/Field/FieldType/FileItem.php
+++ b/core/modules/file/src/Plugin/Field/FieldType/FileItem.php
@@ -249,8 +249,8 @@ public static function validateExtensions($element, FormStateInterface $form_sta
    * fieldSettingsForm().
    */
   public static function validateMaxFilesize($element, FormStateInterface $form_state) {
-    if (!empty($element['#value']) && !is_numeric(Bytes::toInt($element['#value']))) {
-      $form_state->setError($element, t('The "!name" option must contain a valid value. You may either leave the text field empty or enter a string like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes).', array('!name' => t($element['title']))));
+    if (!empty($element['#value']) && !Bytes::toInt($element['#value'])) {
+      $form_state->setError($element, t('The "!name" option must contain a valid value. You may either leave the text field empty or enter a string like "512" (bytes), "80 KB" (kilobytes) or "50 MB" (megabytes).', array('!name' => t($element['#title']))));
     }
   }
 
diff --git a/core/modules/file/tests/src/Unit/Plugin/Field/FieldType/FileItemTest.php b/core/modules/file/tests/src/Unit/Plugin/Field/FieldType/FileItemTest.php
new file mode 100644
index 0000000..e3fbbd0
--- /dev/null
+++ b/core/modules/file/tests/src/Unit/Plugin/Field/FieldType/FileItemTest.php
@@ -0,0 +1,52 @@
+<?php
+
+/**
+ * @file
+ * Contains \Drupal\Tests\file\Unit\Plugin\Field\FieldType\FileItemTest.
+ */
+
+namespace Drupal\Tests\file\Unit\Plugin\Field\FieldType;
+
+use Drupal\Component\Utility\Bytes;
+use Drupal\file\Plugin\Field\FieldType\FileItem;
+use Drupal\Tests\UnitTestCase;
+
+/**
+ * @coversDefaultClass \Drupal\file\Plugin\Field\FieldType\FileItem
+ *
+ * @group file
+ */
+class FileItemTest extends UnitTestCase {
+
+  /**
+   * Data provider for ::testValidateMaxFilesize
+   */
+  public function providerTestValidateMaxFilesize() {
+    return [
+      // Valid.
+      [5, TRUE],
+      ['5M', TRUE],
+      ['5Mb', TRUE],
+      ['5Gb', TRUE],
+      // Invalid.
+      ['five', FALSE],
+      ['fifty megabytes', FALSE],
+    ];
+  }
+
+  /**
+   * @covers ::validateMaxFilesize
+   *
+   * @dataProvider providerTestValidateMaxFilesize
+   */
+  public function testValidateMaxFilesize($filesize, $valid) {
+    $form_state = $this->getMock('\Drupal\Core\Form\FormStateInterface');
+    // If this is valid, then setError should not be called.
+    $form_state->expects($valid ? $this->never() : $this->once())
+      ->method('setError');
+    $element['#value'] = $filesize;
+    $element['#title'] = 'title';
+    FileItem::validateMaxFilesize($element, $form_state);
+  }
+
+}
