示例#1
0
 /**
  * Checks if the passed value is valid.
  *
  * @param mixed      $value      The value that should be validated
  * @param Constraint $constraint The constraint for the validation
  *
  * @api
  */
 public function validate($value, Constraint $constraint)
 {
     $groupName = $constraint->getGroupName();
     foreach ($value as $user) {
         $groups = $user->getGroups();
         foreach ($groups as $group) {
             if ($group->getName() != $groupName) {
                 $this->context->addViolation('message', array('%group%' => $groupName));
             }
         }
     }
 }