KeyNestedException.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. * Exceptions to be thrown by the Attribute Rule.
  10. *
  11. * @author Emmerson Siqueira <emmersonsiqueira@gmail.com>
  12. * @author Henrique Moody <henriquemoody@gmail.com>
  13. * @author Ivan Zinovyev <vanyazin@gmail.com>
  14. */
  15. final class KeyNestedException extends NestedValidationException implements NonOmissibleException
  16. {
  17. public const NOT_PRESENT = 'not_present';
  18. public const INVALID = 'invalid';
  19. /**
  20. * {@inheritDoc}
  21. */
  22. protected $defaultTemplates = [
  23. self::MODE_DEFAULT => [
  24. self::NOT_PRESENT => '找不到密钥链 {{name}} 的项',
  25. self::INVALID => '密钥链 {{name}} 无效',
  26. ],
  27. self::MODE_NEGATIVE => [
  28. self::NOT_PRESENT => '密钥链 {{name}} 的项不存在',
  29. self::INVALID => '密钥链 {{name}} 必须无效',
  30. ],
  31. ];
  32. /**
  33. * {@inheritDoc}
  34. */
  35. protected function chooseTemplate(): string
  36. {
  37. return $this->getParam('hasReference') ? self::INVALID : self::NOT_PRESENT;
  38. }
  39. }