CompositeValidator.php 891 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\Framework\App\Request;
  8. use Magento\Framework\App\ActionInterface;
  9. use Magento\Framework\App\RequestInterface;
  10. /**
  11. * Use sequence of validators to validate requests.
  12. */
  13. class CompositeValidator implements ValidatorInterface
  14. {
  15. /**
  16. * @var ValidatorInterface[]
  17. */
  18. private $validators;
  19. /**
  20. * @param ValidatorInterface[] $validators
  21. */
  22. public function __construct(array $validators)
  23. {
  24. $this->validators = $validators;
  25. }
  26. /**
  27. * @inheritDoc
  28. */
  29. public function validate(
  30. RequestInterface $request,
  31. ActionInterface $action
  32. ): void {
  33. foreach ($this->validators as $validator) {
  34. $validator->validate($request, $action);
  35. }
  36. }
  37. }