@param integer    $rows
@param Constraint $constraint

@throws ConstraintDefinitionException
@return boolean
509628
protected function validateMaxRows($rows, Constraint $constraint)
    {
        if (null !== $constraint->maxRows) {
            if (!ctype_digit((string) $constraint->maxRows)) {
                throw new ConstraintDefinitionException(
                    sprintf(
                        '"%s" is not a valid row size',
                        $constraint->maxRows
                    )
                );
            }

            if ($rows > $constraint->maxRows) {
                $this->context->addViolation(
                    $constraint->maxRowsMessage,
                    array(
                        '{{ max_rows }}' => $constraint->maxRows,
                    )
                );

                return true;
            }
        }
    }
876437
private function validateConstraints(array $constraints): bool
    {
        foreach ($constraints as $constraint) {
            if (!$constraint instanceof Closure && !$constraint instanceof Constraint) {
                return false;
            }
        }

        return true;
    }
535660
public function getCreateConstraintSQL(Constraint $constraint, $table)
    {
        if ($table instanceof Table) {
            $table = $table->getQuotedName($this);
        }

        $query = 'ALTER TABLE ' . $table . ' ADD CONSTRAINT ' . $constraint->getQuotedName($this);

        $columnList = '(' . implode(', ', $constraint->getQuotedColumns($this)) . ')';

        $referencesClause = '';
        if ($constraint instanceof Index) {
            if ($constraint->isPrimary()) {
                $query .= ' PRIMARY KEY';
            } elseif ($constraint->isUnique()) {
                $query .= ' UNIQUE';
            } else {
                throw new InvalidArgumentException(
                    'Can only create primary or unique constraints, no common indexes with getCreateConstraintSQL().'
                );
            }
        } elseif ($constraint instanceof ForeignKeyConstraint) {
            $query .= ' FOREIGN KEY';

            $referencesClause = ' REFERENCES ' . $constraint->getQuotedForeignTableName($this) .
                ' (' . implode(', ', $constraint->getQuotedForeignColumns($this)) . ')';
        }
        $query .= ' ' . $columnList . $referencesClause;

        return $query;
    }
174498
public function validate($value, Constraint $constraint)
    {
        if (null === $value || '' === $value) {
            return;
        }

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

        $schemes = array_flip($constraint->schemes);
        $schemeRegexes = array_intersect_key($this->schemes, $schemes);

        $valid = false;
        foreach ($schemeRegexes as $regexes) {
            foreach ($regexes as $regex) {
                $valid |= preg_match($regex, $value);
            }
        }

        if (!$valid) {
            $this->context->addViolation($constraint->message);
        }
    }
770075
public function validate($data, Constraint $constraint)
    {
        if (!$data instanceof $this->dataClass) {
            $class = \get_class($data);
            throw new \UnexpectedValueException("Can't validate data of class {$class}");
        }
        $context = $this->context; // VERY IMPORTANT ! context will be lost otherwise
        foreach ($data->getFamily()->getAttributes() as $attribute) {
            if ($attribute->isRequired() && $data->isEmpty($attribute)) {
                $this->buildAttributeViolation(
                    $data,
                    $context,
                    $attribute,
                    'required',
                    $data->get($attribute->getCode())
                );
            }
            if ($attribute->isUnique()) {
                $this->checkUnique($context, $attribute, $data);
            }

            if ($attribute->getOption('allowed_families')) {
                $this->validateFamilies($context, $attribute, $data);
            }

            if (\count($attribute->getValidationRules())) {
                $this->validateRules($context, $attribute, $data);
            }
        }
    }
113503
public function validate($location, Constraint $constraint)
    {
        if (null === $location) {
            $this->context->addViolation($constraint->message);

            return;
        }

        $hasChildren = new HasChildren($this->locationService);

        if (!$hasChildren->isSatisfiedBy($location)) {
            $this->context->addViolation($constraint->message);
        }
    }
332110
protected function validateMinColumns($columnsSizes, Constraint $constraint)
    {
        if (null !== $constraint->minColumns) {
            if (!ctype_digit((string) $constraint->minColumns)) {
                throw new ConstraintDefinitionException(
                    sprintf(
                        '"%s" is not a valid column size',
                        $constraint->minColumns
                    )
                );
            }

            foreach ($columnsSizes as $size => $occurrences) {
                if (0 !== $size && $size < $constraint->minColumns) {
                    $this->context->addViolation(
                        $constraint->minColumnsMessage,
                        array(
                            '{{ min_columns }}' => $constraint->minColumns,
                            '{{ occurrences }}' => implode(',', $occurrences)
                        )
                    );

                    return true;
                }
            }
        }
    }
410580
public function validate($value, Constraint $constraint)
    {
        /** @var \Symfony\Component\Form\Form $root */
        $root = $this->context->getRoot();

        /** @var \Generated\Shared\Transfer\QuoteTransfer $data */
        $data = $root->getData();

        $validationMessages = $this->manageMandate($data, $constraint);

        if (count($validationMessages) === 0) {
            return;
        }

        foreach ($validationMessages as $validationMessage) {
            $this->context->buildViolation($validationMessage)
                ->addViolation();
        }
    }
46458
public function validate($location, Constraint $constraint)
    {
        if (null === $location) {
            return;
        }

        $isWithinCopySubtreeLimit = new IsWithinCopySubtreeLimit($this->copySubtreeLimit, $this->searchService);
        try {
            if (!$isWithinCopySubtreeLimit->isSatisfiedBy($location)) {
                $this
                    ->context
                    ->buildViolation($constraint->message)
                    ->setParameter('%currentLimit%', $this->copySubtreeLimit)
                    ->addViolation();
            }
        } catch (InvalidArgumentException $e) {
            $this->context->addViolation($e->getMessage());
        }
    }
392167
public function applyLockingDataBeforeCommit(PersistenceContext $context, array $objects, array $rows)
    {
        $columnName = $this->columnName;

        foreach ($rows as $row) {
            $currentVersion = $row->getColumn($columnName);
            $row->setColumn($columnName, $currentVersion + 1);

            if ($row->hasPrimaryKey()) {
                $row->setLockingColumn($columnName, $currentVersion);
            }
        }
    }
666898
public function validate($value, Constraint $constraint)
    {
        /** @var EntityExists $constraint */
        if ($constraint->validate($value)) {
            $this->context->addViolation(
                $constraint->message,
                [
                    '{{ type }}' => $constraint->entityClass,
                    '{{ value }}' => $value,
                ]
            );
        }
    }
936256
public function equals(Constraint $constraint, $prefix) {
        $prefix .= ': Constraint (' . $this->getName() . '):';
        $errors = [];
        if($constraint->getName() !== $this->getName()) {
            throw new \Exception('Comparing Incomparable Constraints');
        }
        if($constraint->getRemoteTable() !== $this->getRemoteTable()) {
            $errors[] = $prefix . 'Remote Table Does Not Match:' . "\n" . $constraint->getRemoteTable() . "\n" . $this->getRemoteTable();
        }
        $diff = array_diff($constraint->getLocalColumns(), $this->getLocalColumns());
        if(!empty($diff)) {
            $errors[] = $prefix . 'Extra Local Columns: ' . "\n" . implode("\n", $diff);
        }
        $diff = array_diff($this->getLocalColumns(), $constraint->getLocalColumns());
        if(!empty($diff)) {
            $errors[] = $prefix . 'Missing Local Columns: ' . "\n" . implode("\n", $diff);
        }
        $diff = array_diff($constraint->getRemoteColumns(), $this->getRemoteColumns());
        if(!empty($diff)) {
            $errors[] = $prefix . 'Extra Remote Columns: ' . "\n" . implode("\n", $diff);
        }
        $diff = array_diff($this->getRemoteColumns(), $constraint->getRemoteColumns());
        if(!empty($diff)) {
            $errors[] = $prefix . 'Missing Remote Columns: ' . "\n" . implode("\n", $diff);
        }
        if($constraint->getUpdateAction() !== $this->getUpdateAction()) {
            $errors[] = $prefix . 'Update Action Does Not Match:' . "\n" . $constraint->getUpdateAction() . "\n" . $this->getUpdateAction();
        }
        if($constraint->getDeleteAction() !== $this->getDeleteAction()) {
            $errors[] = $prefix . 'Delete Action Does Not Match:' . "\n" . $constraint->getDeleteAction() . "\n" . $this->getDeleteAction();
        }
        return $errors;
    }
374270
public function dropAndCreateConstraint(Constraint $constraint, $table)
    {
        $this->tryMethod('dropConstraint', $constraint, $table);
        $this->createConstraint($constraint, $table);
    }
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;
    }
860830
public function validate($value, Constraint $constraint): void
    {
        // Build a list of values.
        $item_values = [];
        foreach ($value as $item) {
            $item_value = $this->property_accessor->getValue($item, $constraint->property);

            // If any value is repeated build a violation.
            if (isset($item_values[$item_value])) {
                $this->context->buildViolation($constraint->message)
                    ->setParameter('{{ string }}', $constraint->property)
                    ->addViolation();
            }
            $item_values[$item_value] = true;
        }
    }
1048100
public function load(Constraint $constraint)
    {
        $rows = $this->repository->getIterationRows($constraint);

        $context = new \ArrayObject([
            self::BENCHMARKS => [],
            self::SUBJECTS => [],
            self::VARIANTS => [],
            self::SUITES => [],
        ]);

        foreach ($rows as $row) {
            $suite = $this->getSuite($context, $row);
            $benchmark = $this->getBenchmark($context, $suite, $row);
            $subject = $this->getSubject($context, $benchmark, $row);
            $variant = $this->getVariant($context, $subject, $row);
            $iteration = new Iteration(0, $variant, [
                new TimeResult((int) $row['iteration.time']),
                new MemoryResult((int) $row['iteration.memory'], 0, 0),
            ]);
            $variant->addIteration($iteration);
        }

        foreach ($context[self::SUITES] as $suite) {
            foreach ($suite->getVariants() as $variant) {
                $variant->computeStats();
            }
        }

        return new SuiteCollection($context[self::SUITES]);
    }
257050
public function validate($data, Constraint $constraint)
    {
        if (!$constraint instanceof UniqueVariant) {
            throw new \UnexpectedValueException("Can't validate this type of constraint, please provide a UniqueVariant constraint");
        }
        if (!$data instanceof $this->dataClass) {
            $class = get_class($data);
            throw new \UnexpectedValueException("Can't validate data of class {$class}");
        }
        $family = $data->getFamily();
        if (!$family instanceof VariantFamily) {
            return;
        }
        $currentCombination = [];
        foreach ($family->getAxles() as $attribute) {
            if ($attribute->isMultiple()) {
                throw new \LogicException("Family axle '{$attribute->getCode()}' is multiple, multiple axles support is not implemented yet");
            }
            $currentCombination[$attribute->getCode()] = $data->getValueData($attribute);
        }

        /** @var DataInterface $variantData */
        foreach ($constraint->parentData->getValuesData($constraint->attribute) as $variantData) {
            if ($variantData->getFamilyCode() !== $family->getCode()) {
                continue;
            }
            if ($variantData->getId() === $data->getId()) {
                continue;
            }
            $variantDataCombination = [];
            foreach ($family->getAxles() as $attribute) {
                $variantDataCombination[$attribute->getCode()] = $variantData->getValueData($attribute);
            }
            if ($this->compareCombinations($currentCombination, $variantDataCombination)) {
                $this->context->buildViolation('sidus_eav_variant.errors.invalid_axle_combination')
                    ->addViolation();
            }
        }
    }