title: Symfony Validation Class: Undefined property $groups
body: <p>I have the following validation class <code>OneAnswerValidator.php</code>:</p>
  
  <pre><code>&lt;?php
  
  namespace App\Validator\Constraints;
  
  use Symfony\Component\Validator\Constraint;
  use Symfony\Component\Validator\ConstraintValidator;
  use Symfony\Component\Validator\Exception\InvalidArgumentException;
  
  class OneQuestionOneAnswerValidator extends ConstraintValidator {
      // is this necessary? In the docs doesn't appear this property
      //public $groups = [];
  
      public function validate($answers, Constraint $constraint) {
          if (empty($answers)) {
              return;
          }
          $questions = [];
          foreach ($answers as $answer) {
              $questionId = $answer-&gt;getQuestion()-&gt;getId();
              if (isset($questions[$questionId])) {
                  $this-&gt;context
                              -&gt;buildViolation($constraint-&gt;message)
                              -&gt;setParameter('{{ questionId }}', $value)
                              -&gt;addViolation();
                  break;
              }
          }
      }
  }
  </code></pre>
  
  <p>With the associated constraint <code>OneAnswer.php</code>:</p>
  
  <pre><code>&lt;?php
  
  namespace App\Validator\Constraints;
  
  use Symfony\Component\Validator\Constraint;
  
  /**
   * @Annotation
   */
  class OneQuestionOneAnswer extends Constraint
  {
      public $message = 'La pregunta {{ questionId }} tiene varias respuestas';
  }
  </code></pre>
  
  <p>But when the form is submitted I get the following error: </p>
  
  <pre><code>[2018-09-14 13:59:38] request.CRITICAL: Uncaught PHP Exception PHPUnit\Framework\Error\Notice: "Undefined property: App\Validator\Constraints\OneQuestionOneAnswerValidator::$groups" at /Applications/MAMP/htdocs/team-analytics/vendor/symfony/form/Extension/Validator/Constraints/FormValidator.php line 84 {"exception":"[object] (PHPUnit\\Framework\\Error\\Notice(code: 8): Undefined property: App\\Validator\\Constraints\\OneQuestionOneAnswerValidator::$groups at /Applications/MAMP/htdocs/team-analytics/vendor/symfony/form/Extension/Validator/Constraints/FormValidator.php:84)"} []
  </code></pre>
  
  <p>In the documentation there is nothing about a property <code>$groups</code> (but the error get solved when I add that property to <code>OneAnswerValidator</code> class). Any idea why is this happening?</p>
  
  <p>By the way, I am adding the constraint in a Form Type class:</p>
  
  <pre><code>    -&gt;add('answers', EntityType::class, [
          'class' =&gt; Answer::class,
          'choice_label' =&gt; 'title',
          'label' =&gt; 'Respuesta',
          'multiple' =&gt; true,
          'constraints' =&gt; new OneAnswerValidator(['message' =&gt; 'fooo'])
      ]);
  </code></pre>
  
  <p>Thanks!</p>