NotEmptyException.php 1.0 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 Alexandre Gomes Gaigalas <alganet@gmail.com>
  10. * @author Bram Van der Sype <bram.vandersype@gmail.com>
  11. * @author Henrique Moody <henriquemoody@gmail.com>
  12. */
  13. final class NotEmptyException extends ValidationException
  14. {
  15. public const NAMED = 'named';
  16. /**
  17. * {@inheritDoc}
  18. */
  19. protected $defaultTemplates = [
  20. self::MODE_DEFAULT => [
  21. self::STANDARD => '值不能为空',
  22. self::NAMED => '{{name}} 不能为空',
  23. ],
  24. self::MODE_NEGATIVE => [
  25. self::STANDARD => '值必须为空',
  26. self::NAMED => '{{name}} 必须为空',
  27. ],
  28. ];
  29. /**
  30. * {@inheritDoc}
  31. */
  32. protected function chooseTemplate(): string
  33. {
  34. if ($this->getParam('input') || $this->getParam('name')) {
  35. return self::NAMED;
  36. }
  37. return self::STANDARD;
  38. }
  39. }