diff --git a/core/lib/Drupal/Core/Form/FormValidator.php b/core/lib/Drupal/Core/Form/FormValidator.php
index 8e976f5a86..672dcedfb4 100644
--- a/core/lib/Drupal/Core/Form/FormValidator.php
+++ b/core/lib/Drupal/Core/Form/FormValidator.php
@@ -257,10 +257,12 @@ protected function doValidateForm(&$elements, FormStateInterface &$form_state, $
         // length if it's a string, and the item count if it's an array.
         // An unchecked checkbox has a #value of integer 0, different than
         // string '0', which could be a valid value.
-        $is_empty_multiple = (!count($elements['#value']));
+        $test_countability = is_array($elements['#value']) || $elements['#value'] instanceOf Countable;
+        $is_empty_multiple = $test_countability && count($elements['#value']) == 0;
         $is_empty_string = (is_string($elements['#value']) && Unicode::strlen(trim($elements['#value'])) == 0);
         $is_empty_value = ($elements['#value'] === 0);
-        if ($is_empty_multiple || $is_empty_string || $is_empty_value) {
+        $is_empty_null = is_null($elements['#value']);
+        if ($is_empty_multiple || $is_empty_string || $is_empty_value || $is_empty_null) {
           // Flag this element as #required_but_empty to allow #element_validate
           // handlers to set a custom required error message, but without having
           // to re-implement the complex logic to figure out whether the field
