Skip to content

Incomplete core zipcode validation database #23371

Closed
@kapil-infobeans

Description

@kapil-infobeans

Preconditions (*)

  1. Magento EE 2.2.5 with sample data is installed.
  2. Use core class "\Magento\Directory\Model\Country\Postcode\ValidatorInterface" for validation of postcode by countryId
  3. 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

  1. 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 (*)

  1. It should either return true or false.

Actual result (*)

  1. Exception: Provided countryId does not exist.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions