KeyValueException.php 942 B

12345678910111213141516171819202122232425262728293031323334353637
  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 Henrique Moody <henriquemoody@gmail.com>
  10. */
  11. final class KeyValueException extends ValidationException
  12. {
  13. public const COMPONENT = 'component';
  14. /**
  15. * {@inheritDoc}
  16. */
  17. protected $defaultTemplates = [
  18. self::MODE_DEFAULT => [
  19. self::STANDARD => '键 {{name}} 必须存在',
  20. self::COMPONENT => '{{baseKey}} 必须有效才能验证 {{comparedKey}}',
  21. ],
  22. self::MODE_NEGATIVE => [
  23. self::STANDARD => '键 {{name}} 不能存在',
  24. self::COMPONENT => '{{baseKey}} 必须无效才能验证 {{comparedKey}}',
  25. ],
  26. ];
  27. protected function chooseTemplate(): string
  28. {
  29. return $this->getParam('component') ? self::COMPONENT : self::STANDARD;
  30. }
  31. }