Magento Extensions Rating 2024
EXTENSIONS BY CATEGORY
B2B (Business-To-Business)
Blog
Customer
ERP (Enterprise Resource Planning)
Mega Menu
One Step Checkout
Order
POS (Point Of Sale)
Search
Shopping Cart
Sitemap
SEO
Social
Stock & Inventory Management
EXTENSIONS BY DEVELOPER
aheadWorks
Amasty
Boost My Shop
BSS Commerce
Magestore
MageWorx
Mirasvit
Templates Master
Wyomind
XTENTO
Magento 2 Documentation
Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
vendor
magento
module-directory
Model
Country
Postcode
Validator.php
Go to the documentation of this file.
1
<?php
6
namespace
Magento\Directory\Model\Country\Postcode
;
7
8
class
Validator
implements
ValidatorInterface
9
{
13
protected
$postCodesConfig
;
14
18
public
function
__construct
(\
Magento
\Directory\Model\
Country
\Postcode\
ConfigInterface
$postCodesConfig
)
19
{
20
$this->postCodesConfig =
$postCodesConfig
;
21
}
22
26
public
function
validate
($postcode, $countryId)
27
{
28
$postCodes = $this->postCodesConfig->getPostCodes();
29
if
(isset($postCodes[$countryId]) && is_array($postCodes[$countryId])) {
30
$patterns = $postCodes[$countryId];
31
foreach
($patterns as
$pattern
) {
32
preg_match(
'/'
.
$pattern
[
'pattern'
] .
'/'
, $postcode, $matches);
33
if
(count($matches)) {
34
return
true
;
35
}
36
}
37
return
false
;
38
}
39
throw
new \InvalidArgumentException(
'Provided countryId does not exist.'
);
40
}
41
}
Magento\Directory\Model\Country\Postcode
Magento\Directory\Model\Country\Postcode\Validator\$postCodesConfig
$postCodesConfig
Definition:
Validator.php:13
$pattern
$pattern
Definition:
website.php:22
Magento\Directory\Model\Country\Postcode\ConfigInterface
Definition:
ConfigInterface.php:11
Magento\Directory\Model\Country\Postcode\Validator\__construct
__construct(\Magento\Directory\Model\Country\Postcode\ConfigInterface $postCodesConfig)
Definition:
Validator.php:18
Magento\Directory\Model\Country\Postcode\ValidatorInterface
Definition:
ValidatorInterface.php:12
Magento\Directory\Model\Country\Postcode\Validator\validate
validate($postcode, $countryId)
Definition:
Validator.php:26
Magento\Directory\Model\Country
Definition:
Country.php:19
Magento
Magento\AdvancedPricingImportExport\Model\Import\AdvancedPricing\Validator
Definition:
TierPrice.php:6