vendor/symfony/validator/Constraints/NotBlank.php line 25

Open in your IDE?
  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. use Symfony\Component\Validator\Exception\InvalidArgumentException;
  13. /**
  14. * @Annotation
  15. * @Target({"PROPERTY", "METHOD", "ANNOTATION"})
  16. *
  17. * @author Bernhard Schussek <bschussek@gmail.com>
  18. * @author Kévin Dunglas <dunglas@gmail.com>
  19. */
  20. #[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
  21. class NotBlank extends Constraint
  22. {
  23. public const IS_BLANK_ERROR = 'c1051bb4-d103-4f74-8988-acbcafc7fdc3';
  24. protected static $errorNames = [
  25. self::IS_BLANK_ERROR => 'IS_BLANK_ERROR',
  26. ];
  27. public $message = 'This value should not be blank.';
  28. public $allowNull = false;
  29. public $normalizer;
  30. public function __construct(?array $options = null, ?string $message = null, ?bool $allowNull = null, ?callable $normalizer = null, ?array $groups = null, $payload = null)
  31. {
  32. parent::__construct($options ?? [], $groups, $payload);
  33. $this->message = $message ?? $this->message;
  34. $this->allowNull = $allowNull ?? $this->allowNull;
  35. $this->normalizer = $normalizer ?? $this->normalizer;
  36. if (null !== $this->normalizer && !\is_callable($this->normalizer)) {
  37. throw new InvalidArgumentException(sprintf('The "normalizer" option must be a valid callable ("%s" given).', get_debug_type($this->normalizer)));
  38. }
  39. }
  40. }