Hostname.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Validator\Constraints;
  11. use Symfony\Component\Validator\Constraint;
  12. /**
  13. * @Annotation
  14. * @Target({"PROPERTY", "METHOD", "ANNOTATION"})
  15. *
  16. * @author Dmitrii Poddubnyi <dpoddubny@gmail.com>
  17. */
  18. #[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
  19. class Hostname extends Constraint
  20. {
  21. public const INVALID_HOSTNAME_ERROR = '7057ffdb-0af4-4f7e-bd5e-e9acfa6d7a2d';
  22. protected static $errorNames = [
  23. self::INVALID_HOSTNAME_ERROR => 'INVALID_HOSTNAME_ERROR',
  24. ];
  25. public $message = 'This value is not a valid hostname.';
  26. public $requireTld = true;
  27. public function __construct(
  28. array $options = null,
  29. string $message = null,
  30. bool $requireTld = null,
  31. array $groups = null,
  32. $payload = null
  33. ) {
  34. parent::__construct($options, $groups, $payload);
  35. $this->message = $message ?? $this->message;
  36. $this->requireTld = $requireTld ?? $this->requireTld;
  37. }
  38. }