EmailAddress.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * Email address validator
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. namespace Magento\Framework\Validator;
  9. class EmailAddress extends \Zend_Validate_EmailAddress implements \Magento\Framework\Validator\ValidatorInterface
  10. {
  11. /**
  12. * Instantiates hostname validator for local use.
  13. * TLD validation is off by default.
  14. *
  15. * The following option keys are supported:
  16. * 'hostname' => A hostname validator, see Zend_Validate_Hostname
  17. * 'allow' => Options for the hostname validator, see Zend_Validate_Hostname::ALLOW_*
  18. * 'mx' => If MX check should be enabled, boolean
  19. * 'deep' => If a deep MX check should be done, boolean
  20. *
  21. * @inheritdoc
  22. */
  23. public function __construct($options = [])
  24. {
  25. parent::__construct($options);
  26. $this->getHostnameValidator()->setValidateTld(false);
  27. }
  28. /**
  29. * Sets whether or not top-level domains should be validated
  30. *
  31. * @param bool $shouldValidate
  32. * @return void
  33. */
  34. public function setValidateTld(bool $shouldValidate)
  35. {
  36. $this->getHostnameValidator()->setValidateTld($shouldValidate);
  37. }
  38. }