Closed
Description
Preconditions (*)
- Magento EE 2.2.5 with sample data is installed.
- Use core class "\Magento\Directory\Model\Country\Postcode\ValidatorInterface" for validation of postcode by countryId
- Only 94 countries validation database exist in file "app/code/Magento/Directory/etc/zip_codes.xml" out of 246 countries from database table "directory_country"
Steps to reproduce (*)
1.Incomplete core zip-code validation configuration file:
app/code/Magento/Directory/etc/zip_codes.xml
- Code snippet used for testing it.
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('memory_limit', '5G');
error_reporting(E_ALL);
use Magento\Framework\App\Bootstrap;
require 'app/bootstrap.php';
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('Magento\Framework\App\State');
$state->setAreaCode('frontend');
try {
$postalCode = 'KY1-1202';
$countryId = 'KY';
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$postCodeValidator = $objectManager->create(\Magento\Directory\Model\Country\Postcode\ValidatorInterface::class);
$isValid = (bool) $postCodeValidator->validate($postalCode,$countryId);
} catch (\Exception $e) {
echo $e->getMessage();
}
?>
Expected result (*)
- It should either return true or false.
Actual result (*)
- Exception: Provided countryId does not exist.