diff --git a/app/code/Magento/Store/Model/Scope/Validator.php b/app/code/Magento/Store/Model/Scope/Validator.php
index 77138b1460c8864725c9bacd122be37d3e85a15b..3bc91ea3c36f83ce9d272832e4b05a7f7d4fb08b 100644
--- a/app/code/Magento/Store/Model/Scope/Validator.php
+++ b/app/code/Magento/Store/Model/Scope/Validator.php
@@ -50,26 +50,35 @@ class Validator implements ValidatorInterface
             throw new LocalizedException(__('Scope can\'t be empty'));
         }
 
-        if (empty($scopeCode)) {
-            throw new LocalizedException(__('Scope code can\'t be empty'));
-        }
-
-        if (!preg_match('/^[a-z]+[a-z0-9_]*$/', $scopeCode)) {
-            throw new LocalizedException(__('Wrong scope code format'));
-        }
+        $this->validateScopeCode($scopeCode);
 
         try {
             $scopeResolver = $this->scopeResolverPool->get($scope);
+            $scopeResolver->getScope($scopeCode)->getId();
         } catch (InvalidArgumentException $e) {
             throw new LocalizedException(__('Scope "%1" doesn\'t exist', $scope));
-        }
-
-        try {
-            $scopeResolver->getScope($scopeCode)->getId();
         } catch (NoSuchEntityException $e) {
             throw new LocalizedException(__('Scope code "%1" doesn\'t exist in scope "%2"', $scopeCode, $scope));
         }
 
         return true;
     }
+
+    /**
+     * Validate scope code
+     * Throw exception if not valid.
+     *
+     * @param $scopeCode
+     * @throws LocalizedException if scope code is empty or has a wrong format
+     */
+    private function validateScopeCode($scopeCode)
+    {
+        if (empty($scopeCode)) {
+            throw new LocalizedException(__('Scope code can\'t be empty'));
+        }
+
+        if (!preg_match('/^[a-z]+[a-z0-9_]*$/', $scopeCode)) {
+            throw new LocalizedException(__('Wrong scope code format'));
+        }
+    }
 }