CompositeValidator.php 778 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Customer\Model\Address;
  7. /**
  8. * Address composite validator.
  9. */
  10. class CompositeValidator implements ValidatorInterface
  11. {
  12. /**
  13. * @var ValidatorInterface[]
  14. */
  15. private $validators;
  16. /**
  17. * @param array $validators
  18. */
  19. public function __construct(
  20. array $validators = []
  21. ) {
  22. $this->validators = $validators;
  23. }
  24. /**
  25. * @inheritdoc
  26. */
  27. public function validate(AbstractAddress $address)
  28. {
  29. $errors = [];
  30. foreach ($this->validators as $validator) {
  31. $errors = array_merge($errors, $validator->validate($address));
  32. }
  33. return $errors;
  34. }
  35. }