Checks if the passed value is valid.

@param mixed                   $array      The value that should be validated
@param ContainsEnum|Constraint $constraint The constraint for the validation
504402
public function validate($array, Constraint $constraint): void
    {
        if ($array !== null) {
            if (!\is_array($array)) {
                $this->context->buildViolation('Должно быть массивом')
                    ->addViolation();
            } else {
                /**
                 * @var Enum $type
                 */
                $type = $constraint->type;

                $badValues = [];
                foreach ($array as $i => $v) {
                    if (\call_user_func($type . '::check', [$v]) === false) {
                        $badValues[] = $i . ' => ' . $v;
                    }
                }
                if (\count($badValues) > 0) {
                    $this->context->buildViolation($constraint->message)
                        ->setParameter('{{ type }}', $constraint->type)
                        ->setParameter('{{ value }}', implode(', ', $badValues))
                        ->addViolation();
                }
            }
        }
    }
944564
public function validate($value, Constraint $constraint)
    {
        $check = $this->container->get('admin.configuration.configvalue_manager')->getRepository()->findOneBySectionGroupAndValueName(
            $value->getConfigGroup()->getConfigSection()->getName(),
            $value->getConfigGroup()->getName(),
            $value->getName()
        );
        if ( $check && $check->getId() != $value->getId()) {
            $message = $this->container->get('translator')->trans(
                $constraint->message,
                array(
                    '%value%' => $value->getName(),
                    '%group%' => $value->getConfigGroup()->getName(),
                    '%section%' => $value->getConfigGroup()->getConfigSection()->getName()
                ),
                'VinceTAdminConfigurationBundle'
            );
            $this->context->addViolation($message);
        }
    }
1046548
protected static function isArrayElementValidArray(array $array, $key, $validIfNotEmpty = true)
    {
        if (!isset($array[$key])) {
            return false;
        }

        if (!is_array($array[$key])) {
            return false;
        }

        return (!$validIfNotEmpty || !empty($array[$key]));
    }
14996
public function validate($value, Constraint $constraint)
    {
        if (!$value instanceof FieldDefinitionData) {
            return;
        }

        $fieldType = $this->fieldTypeService->getFieldType($value->getFieldTypeIdentifier());
        $this->processValidationErrors($fieldType->validateValidatorConfiguration($value->validatorConfiguration));
    }
514884
protected function isValidArray(array $array, int $maxSize, ?int $minSize = null): void
    {
        $countArray = \count($array);
        if ($minSize !== null && $countArray < $minSize) {
            throw new InvalidArrayException(sprintf('The minimum number of items for this array is %d.', $minSize));
        }
        if ($countArray > $maxSize) {
            throw new InvalidArrayException(sprintf('The maximum number of items for this array is %d.', $maxSize));
        }
    }
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));
        }
    }
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()]
                );
            }
        }
    }
174317
public static function validateMeta(array &$array)
    {

        foreach ($array as $key => $tag) {
            if (!($tag instanceof Meta)) {
                $newtag = new Meta($tag);
                $array[$key] = $newtag;
            }
        }
    }
1110567
public static function containsMultipleTypes(array $array): bool
    {
        if (count($array) > 0) {
            reset($array);
            $previousType = gettype(current($array));
            next($array);
            foreach ($array as $value) {
                if ($previousType !== gettype($value)) {
                    return true;
                }
            }
        }
        return false;
    }
1264564
public function validateScalarArray($array)
    {
        if (!is_array($array)) {
            throw new \InvalidArgumentException(sprintf(
                'Expected array value, got: %s',
                var_export($array, true)
            ));
        }

        foreach ($array as $key => $value) {
            if (false == is_scalar($value)) {
                throw new \InvalidArgumentException(sprintf(
                    'Cannot use an array as a value in a multivalue property. Value was: %s',
                    var_export($array, true)
                ));
            }
        }
    }
1055237
public function validate($value, Constraint $constraint): void
    {
        if (!$constraint instanceof Enum) {
            throw new \RuntimeException(\sprintf('Object of class %s is not instance of %s', \get_class($constraint), Enum::class));
        }

        if (!$constraint->entity) {
            throw new ConstraintDefinitionException('Entity not specified.');
        }

        $constraint->choices = $constraint->entity::getValues();

        parent::validate($value, $constraint);
    }
1056013
public function validate($value, Constraint $constraint)
    {
        /** @var Constraints\Disabled $constraint */
        Assert::isInstanceOf($constraint, Constraints\Disabled::class);

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

        $this->ensureValueImplementsToggleableInterface($value);

        if ($value->isEnabled()) {
            $this->context->addViolation($constraint->message);
        }
    }
461865
public function validate($value, Constraint $constraint)
    {
        $this->values = $constraint->values;
        $startMethod = 'get' . $constraint->startField;
        $endMethod = 'get' . $constraint->endField;
        for ($i = 0; $i < count($value); $i++) {
            $entity = $value[$i];

            $startIdx = $this->getIndex($entity->$startMethod());
            $endIdx = $this->getIndex($entity->$endMethod());

            if ($startIdx >= $endIdx) {
                $this->context->addViolation('error.start_end_time_incoherent');

                return false;
            }
            for ($j = $i + 1; $j < count($value); $j++) {
                $entityToCheck = $value[$j];
                $startIdxToCheck = $this->getIndex($entityToCheck->$startMethod());
                $endIdxToCheck = $this->getIndex($entityToCheck->$endMethod());
                if ($this->idxIsInOtherEntity($startIdx, $startIdxToCheck, $endIdxToCheck) ||
                    $this->idxIsInOtherEntity($endIdx, $startIdxToCheck, $endIdxToCheck) ||
                    $this->entityIsIncludedInAnother($startIdx, $endIdx, $startIdxToCheck, $endIdxToCheck) ||
                    $this->entityIsIncludedInAnother($startIdxToCheck, $endIdxToCheck, $startIdx, $endIdx)
                ) {
                    $this->context->addViolation('error.entities_overlapping', array(
                        '%firstElement%' => $i + 1,
                        '%secondElement%' => $j + 1,
                    ));

                    return false;
                }
            }
        }

        return true;
    }
238382
protected function isArrayValueArray($array)
    {
        if (!is_array($array)) {
            return false;
        }
        foreach ($array as $k => $v) {
            if (!is_array($v)) {
                return false;
            }
        }

        return true;
    }
1197008
public function validate($value, Constraint $constraint)
    {
        if(!$this->isValidNick($value)){
            $this->context->addViolation(
                $constraint->message,
                array('%nickValue%' => $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();
        }
    }
476281
public function compare(array $schema, array $array)
    {
        try {
            // Check if array is associated
            ArrayException::isAssoc($schema);

        } catch (ArrayException $e) {
            !$this->_strict ?: die();
        }

        $this->_schema = $schema;
    }