Validate the value

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

@return null
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);
        }
    }
1318332
public function validate($value, Constraint $constraint)
    {
        if (!$constraint instanceof HasGuessableExtension) {
            throw new UnexpectedTypeException($constraint, __NAMESPACE__ . '\HasGuessableExtension');
        }

        if (!$value instanceof UploadedFile) {
            return;
        }

        $contentType = $this->mimeTypeGuesser->guess($value->getPathname());
        $pathInfo = pathinfo($value->getClientOriginalName());
        if (!array_key_exists('extension', $pathInfo)) {
            $pathInfo['extension'] = $this->extensionGuesser->guess($contentType);
        }

        if ($pathInfo['extension'] === null) {
            $this->context->buildViolation($constraint->notGuessableErrorMessage)
                ->setCode(HasGuessableExtension::NOT_GUESSABLE_ERROR)
                ->addViolation();
        }
    }
966944
public function validate($value, Constraint $constraint)
    {
        if (!$constraint instanceof Bsn) {
            throw new UnexpectedTypeException($constraint, Bsn::class);
        }

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

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

        $value = (string) $value;

        if ('000000000' !== $value && preg_match('/^\d{9}$/', $value)) {
            list($a, $b, $c, $d, $e, $f, $g, $h, $i) = str_split($value);

            $sum = (9 * $a) + (8 * $b) + (7 * $c) + (6 * $d) + (5 * $e) + (4 * $f) + (3 * $g) + (2 * $h) + (-1 * $i);

            if (0 === $sum % 11) {
                return;
            }
        }

        $this->context->buildViolation($constraint->message)
            ->setParameter('{{ value }}', $this->formatValue($value))
            ->addViolation();
    }
412022
public function validate($value, Constraint $constraint)
    {
        if (!$value instanceof SectionUpdateData) {
            return;
        }

        try {
            $section = $this->sectionService->loadSectionByIdentifier($value->identifier);
            if ($section->id == $value->getId()) {
                return;
            }

            $this->context->buildViolation($constraint->message)
                ->atPath('identifier')
                ->setParameter('%identifier%', $value->identifier)
                ->addViolation();
        } catch (NotFoundException $e) {
            // Do nothing
        }
    }
1109121
public function validate($order, Constraint $constraint): void
    {
        /** @var OrderInterface $order */
        Assert::isInstanceOf($order, OrderInterface::class);

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

        /** @var OrderItemInterface[] $orderItems */
        $orderItems = $order->getItems();

        foreach ($orderItems as $orderItem) {
            if (!$orderItem->getProduct()->isEnabled()) {
                $this->context->addViolation(
                    $constraint->message,
                    ['%productName%' => $orderItem->getProduct()->getName()]
                );
            }
        }
    }
14996
public function validate($value, Constraint $constraint)
    {
        if (!$value instanceof FieldDefinitionData) {
            return;
        }

        $fieldType = $this->fieldTypeService->getFieldType($value->getFieldTypeIdentifier());
        $this->processValidationErrors($fieldType->validateValidatorConfiguration($value->validatorConfiguration));
    }
988083
public function validate(
        ConstraintInterface $constraint,
        ConcreteValueInterface &$value,
        PointerInterface $entryPoint = null
    ) {
        $result = $this->validator()->validate($constraint, $value, $entryPoint);
        $value = $this->defaultTransformFactory()
            ->create($result)
            ->transform($value);

        return $result;
    }
1162008
public function validate($file, Constraint $constraint)
    {
        if (!in_array($file->getMimeType(), $this->mimeTypes)) {
            $this->context->buildViolation($constraint->messageMimeTypes)
                ->atPath('file')
                ->addViolation();
        }
        if ($file->getSize() > $file->getMaxFilesize()) {
            $this->context->buildViolation($constraint->messageMaxSize, array('%max_size%' => $file->getMaxFilesize()))
                ->atPath('file')
                ->addViolation();
        }
    }
918084
static function constrain($value, $constraint, $params = [], $helper = NULL) {
    $constraint_method = get_called_class() . '::check' . $constraint;

    if (! is_callable($constraint_method)) throw new \InvalidArgumentException('Invalid constraint method ' . $constraint_method . ' called');

    return call_user_func_array($constraint_method, [$value, (array) $params, $helper]);
  }
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()]
                );
            }
        }
    }
162104
protected function validateDelimiter(Constraint $constraint)
    {
        if (strlen($constraint->delimiter) > 2) {
            throw new ConstraintDefinitionException(sprintf('"%s" is not a valid delimiter', $constraint->delimiter));
        }
    }
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()
        ;
    }
1330059
public function validate($value, Constraint $constraint): void
    {
        if ($value !== null) {
            $type = $constraint->type;
            $values = $type::getValues();
            if (!\in_array($value, $values, true)) {
                $this->context->buildViolation($constraint->message)
                    ->setParameter('{{ type }}', $constraint->type)
                    ->setParameter('{{ value }}', $value)
                    ->addViolation();
            }
        }
    }
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();
            }
        }
    }
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);
        }
    }
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();
            }
        }
    }
637065
public function addConstraint(Constraint $constraint) : void
    {
        $constraint->setValidator($this);
        array_push($this->constraints, $constraint);
    }