Date.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 Date extends Constraint
  20. {
  21. public const INVALID_FORMAT_ERROR = '69819696-02ac-4a99-9ff0-14e127c4d1bc';
  22. public const INVALID_DATE_ERROR = '3c184ce5-b31d-4de7-8b76-326da7b2be93';
  23. protected static $errorNames = [
  24. self::INVALID_FORMAT_ERROR => 'INVALID_FORMAT_ERROR',
  25. self::INVALID_DATE_ERROR => 'INVALID_DATE_ERROR',
  26. ];
  27. public $message = 'This value is not a valid date.';
  28. public function __construct(array $options = null, string $message = null, array $groups = null, $payload = null)
  29. {
  30. parent::__construct($options, $groups, $payload);
  31. $this->message = $message ?? $this->message;
  32. }
  33. }