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