title: Custom constraint validator doesn't allow dependency injection
body: <p>My constraint:</p>
  <pre><code>&lt;?php
  
  declare(strict_types=1);
  
  namespace App\Infrastructure\Domain\Model\Company;
  
  use Symfony\Component\Validator\Constraint;
  
  #[\Attribute]
  class ContainsUnsupportedSymbols extends Constraint
  {
      public string $message = 'The phone &quot;{string}&quot; contains an illegal characters. It can only contain numbers and/or + sign.';
  
      public string $mode;
  }
  </code></pre>
  <p>And my validator:</p>
  <pre><code>&lt;?php
  
  namespace App\Infrastructure\Domain\Model\Company;
  
  
  use Symfony\Component\Validator\Constraint;
  use Symfony\Component\Validator\ConstraintValidator;
  use Symfony\Component\Validator\Exception\UnexpectedTypeException;
  use Symfony\Component\Validator\Exception\UnexpectedValueException;
  use Symfony\Contracts\Translation\TranslatorInterface;
  
  class ContainsUnsupportedSymbolsValidator extends ConstraintValidator
  {
      private TranslatorInterface $translator;
  
      public function __construct(
          TranslatorInterface $translator
      )
      {
      }
  
      public function validate($value, Constraint $constraint)
      {
          if (!$constraint instanceof ContainsUnsupportedSymbols) {
              throw new UnexpectedTypeException($constraint, ContainsUnsupportedSymbols::class);
          }
  
          // custom constraints should ignore null and empty values to allow
          // other constraints (NotBlank, NotNull, etc.) to take care of that
          if (null === $value || '' === $value) {
              return;
          }
  
          if (!is_string($value)) {
              // throw this exception if your validator cannot handle the passed type so that it can be marked as invalid
              throw new UnexpectedValueException($value, 'string');
          }
  
          if (!preg_match('/^\+?[0-9]{3}-?[0-9]{6,12}$/', $value, $matches)) {
              // the argument must be a string or an object implementing __toString()
              $this-&gt;context-&gt;buildViolation(
                  $this-&gt;translator-&gt;trans($constraint-&gt;message, ['{{ string }}', $value])
              )-&gt;addViolation();
          }
      }
  }
  </code></pre>
  <p>This is where I use my constraint:</p>
  <pre><code>'phone' =&gt; [
                      new Assert\NotBlank(),
                      new Assert\Length(
                          min: 1,
                          max: 255,
                      ),
                      new ContainsUnsupportedSymbols()
                  ],
  </code></pre>
  <p>I have to translate the error message but error is thrown because of the constructor not passed parameter.
  Error:
  Too few arguments to function</p>
  <blockquote>
  <p>App\Infrastructure\Domain\Model\Company\ContainsUnsupportedSymbolsValidator::__construct(),
  0 passed in
  /var/www/html/vendor/symfony/validator/ContainerConstraintValidatorFactory.php
  on line 52 and exactly 1 expected</p>
  </blockquote>