@param Constraint $constraint

@throws ConstraintDefinitionException
162104
protected function validateDelimiter(Constraint $constraint)
    {
        if (strlen($constraint->delimiter) > 2) {
            throw new ConstraintDefinitionException(sprintf('"%s" is not a valid delimiter', $constraint->delimiter));
        }
    }
899988
private static function validateConstraint(Constraint $constraint): void
    {
        if (!$constraint instanceof UniqueEntity) {
            throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\UniqueEntity');
        }

        if (!\is_array($constraint->fields) && !\is_string($constraint->fields)) {
            throw new UnexpectedTypeException($constraint->fields, 'array');
        }

        if (null !== $constraint->errorPath && !\is_string($constraint->errorPath)) {
            throw new UnexpectedTypeException($constraint->errorPath, 'string or null');
        }

        if (0 === \count((array) $constraint->fields)) {
            throw new ConstraintDefinitionException('At least one field has to be specified.');
        }
    }
500348
protected function addViolation($value, Constraint $constraint)
    {
        $this->context->buildViolation($constraint->message)
            ->setParameter('%field%', null)
            ->setParameter('%value%', $value)
            ->addViolation()
        ;

        return true;
    }
313718
public function validate($password, Constraint $constraint)
    {
        if (null === $password || '' === $password) {
            $this->context->addViolation($constraint->message);

            return;
        }

        $user = $this->tokenStorage->getToken()->getUser()->getAPIUser();

        if (!$user instanceof User) {
            throw new ConstraintDefinitionException('The User object must implement the UserReference interface.');
        }

        try {
            $this->userService->loadUserByCredentials($user->login, $password);
        } catch (NotFoundException | InvalidArgumentException $e) {
            $this->context->buildViolation($constraint->message)->addViolation();
        }
    }
174498
public function validate($value, Constraint $constraint)
    {
        if (null === $value || '' === $value) {
            return;
        }

        if (!is_numeric($value)) {
            $this->context->addViolation($constraint->message);
        }

        $schemes = array_flip($constraint->schemes);
        $schemeRegexes = array_intersect_key($this->schemes, $schemes);

        $valid = false;
        foreach ($schemeRegexes as $regexes) {
            foreach ($regexes as $regex) {
                $valid |= preg_match($regex, $value);
            }
        }

        if (!$valid) {
            $this->context->addViolation($constraint->message);
        }
    }
946670
public function validate($value, Constraint $constraint)
    {
        if ('' !== $value->getRoutePattern()
            && $this->repository->countByPattern($value->getRoutePattern(), $value->getId()) > 0
        ) {
            $this->context
                ->buildViolation($constraint->message)
                ->atPath('route_pattern')
                ->addViolation();
        }
    }
61577
public function visitDependencyConstraint(ObjectValue\DependencyConstraint $constraint)
    {
        return new ObjectValue\DependencyConstraint(
            $constraint->property(),
            $constraint->schema()->accept($this)
        );
    }
1347187
public function validate($value, Constraint $constraint)
    {
        if (!$value instanceof LanguageCreateStruct) {
            return;
        }

        try {
            $language = $this->languageService->loadLanguage($value->languageCode);
            if ($language->id == $value->getId()) {
                return;
            }

            $this->context->buildViolation($constraint->message)
                ->atPath('language_code')
                ->setParameter('%language_code%', $value->languageCode)
                ->addViolation();
        } catch (NotFoundException $e) {
            // Do nothing
        } catch (InvalidArgumentException $e) {
            // Do nothing
        }
    }
755308
protected function addViolation($value, Constraint $constraint)
    {
        $this->context->buildViolation($constraint->message)
            ->setParameter('%type%', $constraint->className)
            ->setParameter('%fields%', implode(', ', (array) $constraint->fieldNames))
            ->setParameter('%value%', $value)
            ->addViolation()
        ;
    }
322159
public function validate($value, Constraint $constraint)
    {
        if ($value->isInMenu() || $value->isInFooter()) {
            if (preg_match('/{.*}/', $value->getRoutePattern())) {
                $this->context->buildViolation($constraint->message)
                    ->atPath('routePattern')
                    ->addViolation();
            }
        }
    }
911725
protected function validateMaxDuration($duration, Constraint $constraint)
    {
        if ($constraint->maxDuration) {
            if (!ctype_digit((string) $constraint->maxDuration)) {
                throw new ConstraintDefinitionException(
                    sprintf(
                        '"%s" is not a valid maximum duration',
                        $constraint->maxDuration
                    )
                );
            }

            if ($duration > $constraint->maxDuration) {
                $this->context->addViolation(
                    $constraint->maxDurationMessage,
                    array(
                        '{{ duration }}' => $duration,
                        '{{ max_duration }}' => $constraint->maxDuration
                    )
                );

                return true;
            }
        }
    }
792804
private function isRequired(Constraint $constraint): bool
    {
        foreach (self::REQUIRED_CONSTRAINTS as $requiredConstraint) {
            if ($constraint instanceof $requiredConstraint) {
                return true;
            }
        }

        return false;
    }
1197008
public function validate($value, Constraint $constraint)
    {
        if(!$this->isValidNick($value)){
            $this->context->addViolation(
                $constraint->message,
                array('%nickValue%' => $value)
            );
        }
    }
628860
private function isArrayConstraint(Constraint $constraint): bool
    {
        return $constraint instanceof Assert\All // << Applied only on array
            || ($constraint instanceof Assert\Choice
                && true === $constraint->multiple // << expect an array multiple choices
            );
    }
637065
public function addConstraint(Constraint $constraint) : void
    {
        $constraint->setValidator($this);
        array_push($this->constraints, $constraint);
    }
511527
public function validate($entity, Constraint $constraint): void
    {
        /** @var UniqueEntity $constraint */
        $em = Util::getObjectManager($this->registry, $entity, $constraint);
        $fields = (array) $constraint->fields;
        $criteria = $this->getCriteria($entity, $constraint, $em);

        if (null === $criteria) {
            return;
        }

        $result = $this->getResult($entity, $constraint, $criteria, $em);

        if (!$this->isValidResult($result, $entity)) {
            $errorPath = null !== $constraint->errorPath ? $constraint->errorPath : $fields[0];
            $invalidValue = $criteria[$errorPath] ?? $criteria[$fields[0]];

            $this->context->buildViolation($constraint->message)
                ->atPath($errorPath)
                ->setInvalidValue($invalidValue)
                ->addViolation()
            ;
        }
    }
766909
public function validate($value, Constraint $constraint)
    {
        if ( !preg_match('/^[a-z0-9_]+$/', $value) ) {
            $message = $this->container->get('translator')->trans($constraint->message, array('%string%' => $value), 'VinceTAdminConfigurationBundle');
            $this->context->addViolation($message);
        }
    }