ZeroComparisonConstraintTrait.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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\Exception\ConstraintDefinitionException;
  12. /**
  13. * @internal
  14. *
  15. * @author Jan Schädlich <jan.schaedlich@sensiolabs.de>
  16. * @author Alexander M. Turek <me@derrabus.de>
  17. */
  18. trait ZeroComparisonConstraintTrait
  19. {
  20. public function __construct(array $options = null, string $message = null, array $groups = null, $payload = null)
  21. {
  22. if (null === $options) {
  23. $options = [];
  24. }
  25. if (isset($options['propertyPath'])) {
  26. throw new ConstraintDefinitionException(sprintf('The "propertyPath" option of the "%s" constraint cannot be set.', static::class));
  27. }
  28. if (isset($options['value'])) {
  29. throw new ConstraintDefinitionException(sprintf('The "value" option of the "%s" constraint cannot be set.', static::class));
  30. }
  31. parent::__construct(0, null, $message, $groups, $payload, $options);
  32. }
  33. public function validatedBy(): string
  34. {
  35. return parent::class.'Validator';
  36. }
  37. }