@param ArrayValue\ItemsConstraint $constraint

@return Result\ValidationResult
340940
public function visitItemsConstraint(ArrayValue\ItemsConstraint $constraint)
    {
        $value = $this->currentValue();
        if (!$value instanceof Value\ArrayValue) {
            return $this->createResult();
        }

        $result = $this->createResult();
        $matchedIndices = array();

        // items
        foreach ($constraint->schemas() as $index => $schema) {
            if ($value->has($index)) {
                $matchedIndices[$index] = true;
                $result = $result->merge(
                    $this->validateArrayIndex($index, $schema)
                );
            } elseif (null !== $schema->defaultValue()) {
                $result = $result->merge(
                    $this->createResult(
                        array(),
                        array($this->createDefaultValueMatch($schema, $index))
                    )
                );
            }
        }

        // additional items
        foreach ($value->keys() as $index) {
            if (!array_key_exists($index, $matchedIndices)) {
                $result = $result->merge(
                    $this->validateArrayIndex(
                        $index,
                        $constraint->additionalSchema()
                    )
                );
            }
        }

        return $result;
    }
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);
        }
    }
1370833
public function visitUriFormatConstraint(StringValue\UriFormatConstraint $constraint)
    {
        if (!$this->formatValidationEnabled()) {
            return $this->createResult();
        }

        $value = $this->currentValue();
        if (
            !$value instanceof Value\StringValue ||
            $this->uriValidator()->isValid($value->value())
        ) {
            return $this->createResult();
        }

        return $this->createSingleIssueResult($constraint);
    }
115945
protected function compileConstraint($constraint)
    {
        return function ($value) use ($constraint) {

            if (!$value instanceof MatchesCollection) {
                return $this->checker->check($value, $constraint);
            }

            // Matching values against sequential arrays will result in
            // checking if ANY of the values matches the criteria.
            // This will allow normal sql like "WHERE categories.id = 13" queries
            foreach ($value as $item) {
                if ($this->checker->check($item, $constraint)) {
                    return true;
                }
            }

            return false;

        };
    }
1206390
public function validate($value, Constraint $constraint)
    {
        $parentGetter = 'get' . ucfirst($constraint->parent);
        $siblingsGetter = 'get' . ucfirst($constraint->siblings);
        $this->startFieldGetter = 'get' . $constraint->startField;
        $this->endFieldGetter = 'get' . $constraint->endField;
        $entities = $this->seasonManager->findByPerimeter($value->$parentGetter());

        foreach ($entities as $entity) {
            if ($entity->getId() != $value->getId() && (
                // value is contained in entity
                $this->entityIsIncludedInAnother($entity, $value) ||
                // entity is contained in value
                $this->entityIsIncludedInAnother($value, $entity) ||
                // value startDate is within another entity
                ($value->{$this->startFieldGetter}() >= $entity->{$this->startFieldGetter}() &&
                $value->{$this->startFieldGetter}() <= $entity->{$this->endFieldGetter}()) ||
                // value endDate is within another entity
                ($value->{$this->endFieldGetter}() >= $entity->{$this->startFieldGetter}() &&
                $value->{$this->endFieldGetter}() <= $entity->{$this->endFieldGetter}())
                )) {
                $this->context->addViolation(
                    'error.seasons_overlapping',
                    array(
                        '%saison_title%' => $entity->getTitle(),
                    )
                );

                return false;
            }
        }

        return true;
    }
90546
public function validate($value, Constraint $constraint)
    {
        $url = $this->helper->getUrl($value);
        if($this->browser->get($url)->getStatusCode() >= 400) {
            $this->context->addViolation($constraint->message, array('%string%' => $url));
        }
    }
528525
public function visitPropertiesConstraint(ObjectValue\PropertiesConstraint $constraint)
    {
        $value = $this->currentValue();
        if (!$value instanceof Value\ObjectValue) {
            return $this->createResult();
        }

        $result = $this->createResult();
        $matchedProperties = array();

        // properties
        foreach ($constraint->schemas() as $property => $schema) {
            if ($value->has($property)) {
                $matchedProperties[$property] = true;
                $result = $result->merge(
                    $this->validateObjectProperty($property, $schema)
                );
            } elseif (null !== $schema->defaultValue()) {
                $result = $result->merge(
                    $this->createResult(
                        array(),
                        array($this->createDefaultValueMatch($schema, $property))
                    )
                );
            }
        }

        // pattern properties
        foreach ($constraint->patternSchemas() as $pattern => $schema) {
            $pattern = $this->wrapPattern($pattern);

            foreach ($value->keys() as $property) {
                if (preg_match($pattern, $property)) {
                    $matchedProperties[$property] = true;
                    $result = $result->merge(
                        $this->validateObjectProperty($property, $schema)
                    );
                }
            }
        }

        // additional properties
        foreach ($value->keys() as $property) {
            if (!array_key_exists($property, $matchedProperties)) {
                $result = $result->merge(
                    $this->validateObjectProperty(
                        $property,
                        $constraint->additionalSchema()
                    )
                );
            }
        }

        return $result;
    }
79959
public function validate($value, Constraint $constraint)
    {
        /**@var $constraint CodeUnit */
        if (!in_array($value, $this->codes)) {
            $this->context->buildViolation($constraint->message)
                ->setParameter('{{ value }}', $value)
                ->addViolation();
        }
    }
676358
public function visitMinimumItemsConstraint(ArrayValue\MinimumItemsConstraint $constraint)
    {
        $value = $this->currentValue();
        if (
            !$value instanceof Value\ArrayValue ||
            $value->count() >= $constraint->minimum()
        ) {
            return $this->createResult();
        }

        return $this->createSingleIssueResult($constraint);
    }
754899
public function guessPatternForConstraint(Constraint $constraint)
    {
        switch (\get_class($constraint)) {
            case 'Symfony\Component\Validator\Constraints\Length':
                if (is_numeric($constraint->min)) {
                    return new ValueGuess(sprintf('.{%s,}', (string) $constraint->min), Guess::LOW_CONFIDENCE);
                }
                break;

            case 'Symfony\Component\Validator\Constraints\Regex':
                $htmlPattern = $constraint->getHtmlPattern();

                if (null !== $htmlPattern) {
                    return new ValueGuess($htmlPattern, Guess::HIGH_CONFIDENCE);
                }
                break;

            case 'Symfony\Component\Validator\Constraints\Range':
                if (is_numeric($constraint->min)) {
                    return new ValueGuess(sprintf('.{%s,}', \strlen((string) $constraint->min)), Guess::LOW_CONFIDENCE);
                }
                break;

            case 'Symfony\Component\Validator\Constraints\Type':
                if (\in_array($constraint->type, ['double', 'float', 'numeric', 'real'])) {
                    return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
                }
                break;
        }
    }
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();
        }
    }
558765
public function guessMinLengthForConstraint(Constraint $constraint)
    {
        switch (get_class($constraint)) {
            case 'Symfony\Component\Validator\Constraints\Length':
                if (is_numeric($constraint->min)) {
                    return new ValueGuess($constraint->min, Guess::HIGH_CONFIDENCE);
                }
                break;
            case 'Symfony\Component\Validator\Constraints\Type':
                if (in_array($constraint->type, array('double', 'float', 'numeric', 'real'))) {
                    return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE);
                }
                break;
            case 'Symfony\Component\Validator\Constraints\Range':
                if (is_numeric($constraint->min)) {
                    return new ValueGuess(strlen((string) $constraint->min), Guess::LOW_CONFIDENCE);
                }
                break;
        }
    }
339935
public function validate($addCartItemCommand, Constraint $constraint): void
    {
        Assert::isInstanceOf($addCartItemCommand, AddToCartCommandInterface::class);
        Assert::isInstanceOf($constraint, CartItemAvailability::class);

        /** @var OrderItemInterface $cartItem */
        $cartItem = $addCartItemCommand->getCartItem();

        $isStockSufficient = $this->availabilityChecker->isStockSufficient(
            $cartItem->getVariant(),
            $cartItem->getQuantity() + $this->getExistingCartItemQuantityFromCart($addCartItemCommand->getCart(), $cartItem)
        );

        if (!$isStockSufficient) {
            $this->context->addViolation(
                $constraint->message,
                ['%itemName%' => $cartItem->getVariant()->getInventoryName()]
            );
        }
    }
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
            );
    }
640932
public function visitMinimumConstraint(NumberValue\MinimumConstraint $constraint)
    {
        $value = $this->currentValue();
        if (
            !$value instanceof Value\NumberValueInterface ||
            $value->value() >= $constraint->minimum()
        ) {
            return $this->createResult();
        }

        return $this->createSingleIssueResult($constraint);
    }
1330237
public function visitMaximumPropertiesConstraint(ObjectValue\MaximumPropertiesConstraint $constraint)
    {
        $value = $this->currentValue();
        if (
            !$value instanceof Value\ObjectValue ||
            $value->count() <= $constraint->maximum()
        ) {
            return $this->createResult();
        }

        return $this->createSingleIssueResult($constraint);
    }
637065
public function addConstraint(Constraint $constraint) : void
    {
        $constraint->setValidator($this);
        array_push($this->constraints, $constraint);
    }