Validate the section

@param string     $section    [description]
@param Constraint $constraint [description]

@return null
764492
public function validate($section, Constraint $constraint)
    {
        $check = $this->container->get('admin.configuration.configsection_manager')->getRepository()->findOneByName($section->getName());
        if ( $check && $check->getId() !== $section->getId() ) {
            $message = $this->container->get('translator')->trans(
                $constraint->message,
                array(
                    '%section%' => $section->getName()
                ),
                'VinceTAdminConfigurationBundle'
            );
            $this->context->addViolation($message);
        }
    }
1015620
public function validate($value, Constraint $constraint)
    {
        if($value instanceof SubscriberInterface) {
            if($this->manager->exists($value, $value->getType())) {
                $this->context->buildViolation($constraint->message)
                    ->setParameter('%email%', $value->getEmail())
                    ->addViolation();
            }
        }
    }
1236724
public function validate($array, Constraint $constraint): void
    {
        if (\is_array($array)) {
            $type = $constraint->type;
            $values = $type::getValues();
            $badValues = [];
            foreach ($array as $v) {
                if (!\in_array($v, $values, true)) {
                    $badValues[] = $v;
                }
            }
            if ($badValues) {
                $this->context->buildViolation($constraint->message)
                    ->setParameter('{{ type }}', $constraint->type)
                    ->setParameter('{{ value }}', implode(', ', $badValues))
                    ->addViolation();
            }
        }
    }
23397
public function validate($value, Constraint $constraint)
    {
        try {
            $value->getMainAlias();
        } catch (MainAliasNotExisting $exception) {
            foreach ($value->getAliases() as $name => $siteAlias) {
                $this->context->buildViolation($constraint->message)
                    ->atPath('aliases['.$name.'].main')
                    ->addViolation();
            }
        }
    }
1146524
public function validate($order, Constraint $constraint): void
    {
        /** @var OrderInterface $order */
        Assert::isInstanceOf($order, OrderInterface::class);

        /** @var OrderShippingMethodEligibility $constraint */
        Assert::isInstanceOf($constraint, OrderShippingMethodEligibility::class);

        $shipments = $order->getShipments();
        if ($shipments->isEmpty()) {
            return;
        }

        foreach ($shipments as $shipment) {
            if (!$this->methodEligibilityChecker->isEligible($shipment, $shipment->getMethod())) {
                $this->context->addViolation(
                    $constraint->message,
                    ['%shippingMethodName%' => $shipment->getMethod()->getName()]
                );
            }
        }
    }
442079
public function validate($location, Constraint $constraint)
    {
        if (null === $location) {
            $this->context->addViolation($constraint->message);

            return;
        }

        $isContainer = new IsContainer();
        if (!$isContainer->isSatisfiedBy($location)) {
            $this->context->addViolation($constraint->message);
        }
    }
1139007
public function validate($value, Constraint $constraint)
    {
        if (null === $value || '' === $value) {
            return;
        }

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

        $length = strlen($value);
        $oddLength = $length % 2;
        for ($sum = 0, $i = $length - 1; $i >= 0; --$i) {
            $digit = (int) $value[$i];
            $sum += (($i % 2) === $oddLength) ? array_sum(str_split($digit * 2)) : $digit;
        }

        if (($sum % 10) !== 0) {
            $this->context->addViolation($constraint->message);
        }
    }
959405
public function validate($value, Constraint $constraint)
    {
        $constraintClass = $this->getValidatorConstraintClass();

        if (get_class($constraint) !== $constraintClass) {
            throw new UnexpectedTypeException($constraint, $constraintClass);
        }

        if (null === $value || '' === $value) {
            return;
        }

        if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
            throw new UnexpectedTypeException($value, 'string');
        }

        $value = (string) $value;

        $validator = $this->getBaseValidator();
        if (!$validator->isValid($value, $this->getValidationOptions($constraint))) {
            if ($this->context instanceof ExecutionContextInterface) {
                $this->context->buildViolation($constraint->message)
                    ->setParameter('{{ value }}', $this->formatValue($value))
                    ->addViolation();
            } else {
                $this->buildViolation($constraint->message)
                    ->setParameter('{{ value }}', $this->formatValue($value))
                    ->addViolation();
            }
        }
    }
1144087
public function validate($value, Constraint $constraint)
    {
        if ($value === null) {
            return;
        }

        $chunks = \explode('.', (string) $value);
        if (\count($chunks) > 2) {
            throw new \Exception('Number can have only 1 "." character.');
        }

        $precision = \strlen(\implode('', $chunks));
        $scale = isset($chunks[1]) ? \strlen($chunks[1]) : 0;

        if ($constraint->precision !== null && $precision > $constraint->precision) {
            $this->context->addViolation($constraint->precisionMessage, [
                '%maxPrecision%' => $constraint->precision,
            ]);
        }

        if ($constraint->scale !== null && $scale > $constraint->scale) {
            $this->context->addViolation($constraint->scaleMessage, [
                '%maxScale%' => $constraint->scale,
            ]);
        }
    }
1328159
public function isValid($value, Constraint $constraint)
    {
        $document = $this->parseDocument($value);
        $fields = $this->parseFields($constraint->fields);
        $caseInsensitive = $this->parseCaseInsensitive($constraint->caseInsensitive);

        $query = $this->createQuery($document, $fields, $caseInsensitive);
        $numberResults = $query->count();

        if (0 === $numberResults) {
            return true;
        }

        if (1 === $numberResults) {
            $result = $query->one();
            if ($result === $document) {
                return true;
            }
        }

        if ($this->context) {
            $this->addFieldViolation($fields[0], $constraint->message);
        }

        return false;
    }
37110
public function validate($value, Constraint $constraint)
    {
        if (!$value instanceof FieldDefinitionData) {
            return;
        }

        $contentTypeData = $value->contentTypeData;
        foreach ($contentTypeData->fieldDefinitionsData as $fieldDefData) {
            if ($fieldDefData === $value) {
                continue;
            }

            if ($value->identifier === $fieldDefData->identifier) {
                $this->context->buildViolation($constraint->message)
                    ->atPath('identifier')
                    ->setParameter('%identifier%', $value->identifier)
                    ->addViolation();
            }
        }
    }
432430
public function validate($order, Constraint $constraint): void
    {
        /** @var OrderInterface $order */
        Assert::isInstanceOf($order, OrderInterface::class);

        /** @var OrderPaymentMethodEligibility $constraint */
        Assert::isInstanceOf($constraint, OrderPaymentMethodEligibility::class);

        $payments = $order->getPayments();

        foreach ($payments as $payment) {
            if (!$payment->getMethod()->isEnabled()) {
                $this->context->addViolation(
                    $constraint->message,
                    ['%paymentMethodName%' => $payment->getMethod()->getName()]
                );
            }
        }
    }
698208
public function validate($repo, Constraint $constraint)
    {
        if($this->repoManager->isExists($repo)) {
            $this->context->addViolation($constraint->message, array('string' => $repo->getSlug()));
        }
    }
666484
public function section($section, $position = null)
    {
        if (is_string($section)) {
            $section = new FormSection($section);
        }

        return null !== $position ? $this->insert($section, $position) : $this->push($section);
    }
1141134
public function validate($value, Constraint $constraint)
    {
        if (!$value) {
            return;
        }

        $fileHistory = $this->em->getRepository('JbFileUploaderBundle:FileHistory')->find($value);
        if (!$fileHistory) {
            return;
        }

        // No userid associated with file. Every one can use it.
        if (!$fileHistory->getUserId()) {
            return;
        }

        // No token. Violation as there is a user id associate with file.
        $token = $this->tokenStorage->getToken();
        if (!$token) {
            return $this->createViolation($value, $constraint);
        }

        // No user. Violation as there is a user id associate with file.
        $user = $token->getUser();
        if (!$user) {
            return $this->createViolation($value, $constraint);
        }

        if ($user->getId() !== $fileHistory->getUserId()) {
            return $this->createViolation($value, $constraint);
        }

        return;
    }
481261
public function validate($value, Constraint $constraint)
    {
        if (!$constraint instanceof PasswordRestrictions) {
            throw new UnexpectedTypeException($constraint, __NAMESPACE__ . '\PasswordRestrictions');
        }

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

        if (null !== $this->minLength) {
            $this->validateMinLength($value);
        }

        if (null !== $this->maxLength) {
            $this->validateMaxLength($value);
        }

        if (null !== $this->minDigits) {
            $this->validateMinDigits($value);
        }

        if (null !== $this->minUppercase) {
            $this->validateMinUppercase($value);
        }

        if (null !== $this->minSpecialCharacters) {
            $this->validateMinSpecialCharacters($value);
        }
    }
1236332
public function validate($value, Constraint $constraint)
    {
        if (is_array($value)) {
            $value = json_encode($value);
        }

        if (!json_decode($value, true)) {
            $this->context->addViolation(
                $constraint->message,
                array()
            );
        }
    }