UuidException.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /*
  3. * Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
  4. * SPDX-License-Identifier: MIT
  5. */
  6. declare(strict_types=1);
  7. namespace Respect\Validation\Exceptions;
  8. /**
  9. * @author Dick van der Heiden <d.vanderheiden@inthere.nl>
  10. * @author Henrique Moody <henriquemoody@gmail.com>
  11. * @author Michael Weimann <mail@michael-weimann.eu>
  12. */
  13. final class UuidException extends ValidationException
  14. {
  15. public const VERSION = 'version';
  16. /**
  17. * {@inheritDoc}
  18. */
  19. protected $defaultTemplates = [
  20. self::MODE_DEFAULT => [
  21. self::STANDARD => '{{name}} 必须是有效的UUID',
  22. self::VERSION => '{{name}} 必须是有效的UUID版本 {{version}}',
  23. ],
  24. self::MODE_NEGATIVE => [
  25. self::STANDARD => '{{name}} 不能是有效的UUID',
  26. self::VERSION => '{{name}} 不能是有效的UUID版本 {{version}}',
  27. ],
  28. ];
  29. /**
  30. * {@inheritDoc}
  31. */
  32. protected function chooseTemplate(): string
  33. {
  34. if ($this->getParam('version')) {
  35. return self::VERSION;
  36. }
  37. return self::STANDARD;
  38. }
  39. }