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-inventory
Model
Source
Validator
PostcodeValidator.php
Go to the documentation of this file.
1
<?php
6
declare(strict_types=1);
7
8
namespace
Magento\Inventory\Model\Source\Validator
;
9
10
use
Magento\Framework\Validation\ValidationResult
;
11
use Magento\Framework\Validation\ValidationResultFactory;
12
use
Magento\InventoryApi\Api\Data\SourceInterface
;
13
use
Magento\InventoryApi\Model\SourceValidatorInterface
;
14
18
class
PostcodeValidator
implements
SourceValidatorInterface
19
{
23
private
$validationResultFactory;
24
28
public
function
__construct
(ValidationResultFactory $validationResultFactory)
29
{
30
$this->validationResultFactory = $validationResultFactory;
31
}
32
36
public
function
validate
(
SourceInterface
$source
):
ValidationResult
37
{
38
$value
= (string)
$source
->getPostcode();
39
40
if
(
''
=== trim(
$value
)) {
41
$errors
[] =
__
(
'"%field" can not be empty.'
, [
'field'
=>
SourceInterface::POSTCODE
]);
42
}
else
{
43
$errors
= [];
44
}
45
return
$this->validationResultFactory->create([
'errors'
=>
$errors
]);
46
}
47
}
Magento\Inventory\Model\Source\Validator\PostcodeValidator\validate
validate(SourceInterface $source)
Definition:
PostcodeValidator.php:36
Magento\Inventory\Model\Source\Validator
Definition:
CodeValidator.php:8
$source
$source
Definition:
source.php:23
Magento\InventoryApi\Model\SourceValidatorInterface
Definition:
SourceValidatorInterface.php:19
__
__()
Definition:
__.php:13
Magento\Inventory\Model\Source\Validator\PostcodeValidator\__construct
__construct(ValidationResultFactory $validationResultFactory)
Definition:
PostcodeValidator.php:28
$value
$value
Definition:
gender.phtml:16
Magento\Inventory\Model\Source\Validator\PostcodeValidator
Definition:
PostcodeValidator.php:18
Magento\InventoryApi\Api\Data\SourceInterface\POSTCODE
const POSTCODE
Definition:
SourceInterface.php:35
Magento\InventoryApi\Api\Data\SourceInterface
Definition:
SourceInterface.php:17
$errors
$errors
Definition:
overview.phtml:9
Magento\Framework\Validation\ValidationResult
Definition:
ValidationResult.php:16