Skip to content

Commit

Permalink
Merge pull request #33 from AleksandrsKondratjevs/master
Browse files Browse the repository at this point in the history
Replace zend validator with laminas
  • Loading branch information
AleksandrsKondratjevs authored Apr 12, 2023
2 parents 906358f + 4f7db76 commit 50dc670
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/Model/Resolver/ShareWishlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
use Magento\Store\Model\StoreManagerInterface;
use Magento\Wishlist\Model\WishlistFactory;
use ScandiPWA\WishlistGraphQl\Model\Resolver\WishlistResolver;
use Laminas\Validator\EmailAddress;

class ShareWishlist implements ResolverInterface
{
Expand Down Expand Up @@ -69,6 +70,12 @@ class ShareWishlist implements ResolverInterface
*/
protected $layoutFactory;

/**
* @var EmailAddress
*/
protected $emailValidator;


/**
* @param Escaper $escaper
* @param UrlInterface $url
Expand All @@ -79,6 +86,7 @@ class ShareWishlist implements ResolverInterface
* @param TransportBuilder $transportBuilder
* @param StoreManagerInterface $storeManager
* @param CustomerRepository $customerRepository
* @param EmailAddress $emailAddress
*/
public function __construct(
Escaper $escaper,
Expand All @@ -89,7 +97,8 @@ public function __construct(
WishlistResolver $wishlistResolver,
TransportBuilder $transportBuilder,
StoreManagerInterface $storeManager,
CustomerRepository $customerRepository
CustomerRepository $customerRepository,
EmailAddress $emailValidator
) {
$this->url = $url;
$this->escaper = $escaper;
Expand All @@ -100,6 +109,7 @@ public function __construct(
$this->wishlistResolver = $wishlistResolver;
$this->transportBuilder = $transportBuilder;
$this->customerRepository = $customerRepository;
$this->emailValidator = $emailValidator;
}

/**
Expand Down Expand Up @@ -145,7 +155,7 @@ public function resolve(
continue;
}

if (!\Zend_Validate::is($email, \Magento\Framework\Validator\EmailAddress::class)) {
if (!$this->emailValidator->isValid($email)) {
throw new GraphQlInputException(__('Provided emails are not valid'));
}

Expand Down

0 comments on commit 50dc670

Please sign in to comment.