{@inheritDoc}

@param Constraint $value A Constraint instance
485297
public function set($key, $value)
    {
        $this->assertConstraintInstance($value);

        parent::set($key, $value);
    }
666898
public function validate($value, Constraint $constraint)
    {
        /** @var EntityExists $constraint */
        if ($constraint->validate($value)) {
            $this->context->addViolation(
                $constraint->message,
                [
                    '{{ type }}' => $constraint->entityClass,
                    '{{ value }}' => $value,
                ]
            );
        }
    }
1173885
public function validate($entity, Constraint $constraint): void
    {
        /** @var HasEnabledEntity $constraint */
        Assert::isInstanceOf($constraint, HasEnabledEntity::class);

        $enabled = $this->accessor->getValue($entity, $constraint->enabledPath);

        if ($enabled === true) {
            return;
        }

        $objectManager = $this->getProperObjectManager($constraint->objectManager, $entity);

        $this->ensureEntityHasProvidedEnabledField($objectManager, $entity, $constraint->enabledPath);

        $criteria = [$constraint->enabledPath => true];

        $repository = $objectManager->getRepository(get_class($entity));
        $results = $repository->{$constraint->repositoryMethod}($criteria);

        /* If the result is a MongoCursor, it must be advanced to the first
         * element. Rewinding should have no ill effect if $result is another
         * iterator implementation.
         */
        if ($results instanceof \Iterator) {
            $results->rewind();
        } elseif (is_array($results)) {
            reset($results);
        }

        if ($this->isLastEnabledEntity($results, $entity)) {
            $errorPath = null !== $constraint->errorPath ? $constraint->errorPath : $constraint->enabledPath;

            $this->context->buildViolation($constraint->message)->atPath($errorPath)->addViolation();
        }
    }
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()]
                );
            }
        }
    }
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);
        }
    }
251785
public function addPropertyConstraint($property, Constraint $constraint)
    {
        if (!isset($this->properties[$property])) {
            $this->properties[$property] = new PropertyMetadata($this->getClassName(), $property);

            $this->addPropertyMetadata($this->properties[$property]);
        }

        $constraint->addImplicitGroupName($this->getDefaultGroup());

        $this->properties[$property]->addConstraint($constraint);

        return $this;
    }
613429
protected function createViolation($value, Constraint $constraint)
    {
        $this
            ->context
            ->buildViolation($constraint->message)
            ->setParameter('%filename%', $value)
            ->addViolation();
    }
1303735
public function validate($value, Constraint $constraint)
    {
        $result = $this->repository->hasOtherNodeWithSameParentAndOrder(
            $value->getParentId(),
            $value->getOrder(),
            $value->getNodeId(),
            $value->getSiteId()
        );

        if (true === $result) {
            $this->context->buildViolation($constraint->message)->addViolation();
        }
    }
693826
public function validate($value, Constraint $constraint)
    {
        try {
            if (null !== $value) {
                $array = json_decode($value, true);
                if (!\is_array($array)) {
                    throw new \Exception();
                }

                return $array;
            }
        } catch (\Exception $e) {
            $this->context->buildViolation('victoire.config.json.invalid')
                ->setParameter('{{ value }}', $value)
                ->addViolation();
        }
    }
735956
protected function hasEntity($value, Constraint $constraint)
    {
        $repo = $this->em->getRepository($constraint->className);
        /** @var Entity $formEntity */
        $formEntity = $this->context->getRoot()->getData();
        $query = $repo->createQueryBuilder()
            ->setParameter('value', $value)
        ;
        foreach ((array) $constraint->fieldNames as $fieldName) {
            $query->orWhere($fieldName . ' = :value');
        }

        $entity = $repo->findOneWith($query);
        if ($entity === false) {
            return false;
        }
        if ($entity->getId() === $formEntity->getId()) {
            return false;
        }

        return true;
    }
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()
            );
        }
    }
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();
            }
        }
    }
1009799
protected function addViolation($value, Constraint $constraint)
    {
        $this->context->addViolation(
            $constraint->message,
            [
                '{{ id_field }}' => $constraint->getIdField(),
                '{{ value }}'    => $value
            ],
            $value
        );
    }
1373252
public function validate($value, Constraint $constraint)
    {
        if (null !== $value->getSpecialPageName()) {
            $countSpecialPage = $this->repository->countOtherNodeWithSameSpecialPageName(
                $value->getNodeId(),
                $value->getSiteId(),
                $value->getLanguage(),
                $value->getSpecialPageName()
            );

            if ($countSpecialPage > 0) {
                $this->context->buildViolation($constraint->message)
                    ->atPath('specialPageName')
                    ->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]);
  }
500348
protected function addViolation($value, Constraint $constraint)
    {
        $this->context->buildViolation($constraint->message)
            ->setParameter('%field%', null)
            ->setParameter('%value%', $value)
            ->addViolation()
        ;

        return true;
    }
837492
private boolean meetsConstraint(String value, String constraint) {
        return (constraint == null) || constraint.equals(value);
    }