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
NameValidator.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
NameValidator
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
->getName();
39
40
if
(
''
=== trim(
$value
)) {
41
$errors
[] =
__
(
'"%field" can not be empty.'
, [
'field'
=>
SourceInterface::NAME
]);
42
}
else
{
43
$errors
= [];
44
}
45
return
$this->validationResultFactory->create([
'errors'
=>
$errors
]);
46
}
47
}
Magento\Inventory\Model\Source\Validator\NameValidator\__construct
__construct(ValidationResultFactory $validationResultFactory)
Definition:
NameValidator.php:28
Magento\Inventory\Model\Source\Validator
Definition:
CodeValidator.php:8
$source
$source
Definition:
source.php:23
Magento\InventoryApi\Model\SourceValidatorInterface
Definition:
SourceValidatorInterface.php:19
Magento\Inventory\Model\Source\Validator\NameValidator
Definition:
NameValidator.php:18
__
__()
Definition:
__.php:13
$value
$value
Definition:
gender.phtml:16
Magento\InventoryApi\Api\Data\SourceInterface
Definition:
SourceInterface.php:17
Magento\InventoryApi\Api\Data\SourceInterface\NAME
const NAME
Definition:
SourceInterface.php:23
Magento\Inventory\Model\Source\Validator\NameValidator\validate
validate(SourceInterface $source)
Definition:
NameValidator.php:36
$errors
$errors
Definition:
overview.phtml:9
Magento\Framework\Validation\ValidationResult
Definition:
ValidationResult.php:16