Time.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 Bernhard Schussek <bschussek@gmail.com>
  17. */
  18. #[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
  19. class Time extends Constraint
  20. {
  21. public const INVALID_FORMAT_ERROR = '9d27b2bb-f755-4fbf-b725-39b1edbdebdf';
  22. public const INVALID_TIME_ERROR = '8532f9e1-84b2-4d67-8989-0818bc38533b';
  23. protected static $errorNames = [
  24. self::INVALID_FORMAT_ERROR => 'INVALID_FORMAT_ERROR',
  25. self::INVALID_TIME_ERROR => 'INVALID_TIME_ERROR',
  26. ];
  27. public $message = 'This value is not a valid time.';
  28. public function __construct(
  29. array $options = null,
  30. string $message = null,
  31. array $groups = null,
  32. $payload = null
  33. ) {
  34. parent::__construct($options, $groups, $payload);
  35. $this->message = $message ?? $this->message;
  36. }
  37. }