Skip to content

Commit 738792e

Browse files
committed
Add lib wrapper for UUID validation.
1 parent cc599e5 commit 738792e

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

app/etc/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
<preference for="Magento\Framework\EntityManager\MapperInterface" type="Magento\Framework\EntityManager\CompositeMapper"/>
168168
<preference for="Magento\Framework\Console\CommandListInterface" type="Magento\Framework\Console\CommandList"/>
169169
<preference for="Magento\Framework\DataObject\IdentityGeneratorInterface" type="Magento\Framework\DataObject\IdentityService" />
170+
<preference for="Magento\Framework\DataObject\IdentityValidatorInterface" type="Magento\Framework\DataObject\IdentityValidator" />
170171
<preference for="Magento\Framework\Serialize\SerializerInterface" type="Magento\Framework\Serialize\Serializer\Json" />
171172
<preference for="Magento\Framework\App\Scope\ValidatorInterface" type="Magento\Framework\App\Scope\Validator"/>
172173
<preference for="Magento\Framework\App\ScopeResolverInterface" type="Magento\Framework\App\ScopeResolver" />
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Framework\DataObject;
7+
8+
use Ramsey\Uuid\Uuid;
9+
10+
/**
11+
* Class IdentityValidator
12+
*/
13+
class IdentityValidator implements IdentityValidatorInterface
14+
{
15+
/**
16+
* @inheritDoc
17+
*/
18+
public function isValid($value)
19+
{
20+
$isValid = Uuid::isValid($value);
21+
return $isValid;
22+
}
23+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Framework\DataObject;
7+
8+
/**
9+
* Interface IdentityValidatorInterface
10+
*/
11+
interface IdentityValidatorInterface
12+
{
13+
/**
14+
* Checks if uuid is valid
15+
*
16+
* @param string $value
17+
*
18+
* @return string
19+
*/
20+
public function isValid($value);
21+
}

0 commit comments

Comments
 (0)