@param array      $columnsSizes
@param Constraint $constraint

@throws ConstraintDefinitionException
@return boolean
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;
                }
            }
        }
    }
1351429
public function setConstraint($constraint) 
    {
        if (!$this->_isNumericArray($constraint)) {
            $constraint =  array ($constraint);    
        }
        $this->_fields['Constraint']['FieldValue'] = $constraint;
        return $this;
    }
88327
protected function constraintMessages(Constraint $constraint)
    {
        $result = [];
        if (isset($constraint->min) && $constraint->min !== null) {
            $count = new Count(['min' => $constraint->min]);
            $length = new Length(['min' => $constraint->min]);
            $result[] = $constraint->minMessage;
        }
        if (isset($constraint->max) && $constraint->max !== null) {
            $count = new Count(['max' => $constraint->min]);
            $length = new Length(['max' => $constraint->min]);
            $result[] = $constraint->maxMessage;
        }
        if (isset($constraint->exactMessage)
            && $constraint->exactMessage !== $count->exactMessage
            && $constraint->exactMessage !== $length->exactMessage
        ) {
            $result[] = $constraint->exactMessage;
        }

        return $result;
    }
432430
public function validate($order, Constraint $constraint): void
    {
        /** @var OrderInterface $order */
        Assert::isInstanceOf($order, OrderInterface::class);

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

        $payments = $order->getPayments();

        foreach ($payments as $payment) {
            if (!$payment->getMethod()->isEnabled()) {
                $this->context->addViolation(
                    $constraint->message,
                    ['%paymentMethodName%' => $payment->getMethod()->getName()]
                );
            }
        }
    }
1221315
private function detectOneToOne($constraint, $primaryColumns)
    {
        $foreignColumns = $constraint->getLocalColumns();
        sort($foreignColumns);

        return $primaryColumns === $foreignColumns;
    }
570893
public function guessMaxLengthForConstraint(Constraint $constraint)
    {
        switch (\get_class($constraint)) {
            case 'Symfony\Component\Validator\Constraints\Length':
                if (is_numeric($constraint->max)) {
                    return new ValueGuess($constraint->max, Guess::HIGH_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;

            case 'Symfony\Component\Validator\Constraints\Range':
                if (is_numeric($constraint->max)) {
                    return new ValueGuess(\strlen((string) $constraint->max), Guess::LOW_CONFIDENCE);
                }
                break;
        }
    }
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;
    }
252472
public function dropForeignKey($columns, $constraint = null)
    {
        $action = DropForeignKey::build($this->table, $columns, $constraint);
        $this->actions->addAction($action);

        return $this;
    }
935514
private function hasUniqueConstraint(ClassMetadata $metadata, array $columns)
    {
        if (!isset($metadata->table['uniqueConstraints'])) {
            return false;
        }

        foreach ($metadata->table['uniqueConstraints'] as $constraint) {
            if (!array_diff($constraint['columns'], $columns)) {
                return true;
            }
        }

        return false;
    }
1171271
protected function validateEscape(Constraint $constraint)
    {
        if (strlen($constraint->escape) > 2) {
            throw new ConstraintDefinitionException(sprintf('"%s" is not a valid escape', $constraint->escape));
        }
    }
595540
protected function _getPrimaryConstraint(Constraint\Primary $constraint)
    {
        $columns = implode(', ', $constraint->getColumnNames());
        return sprintf(
            'CONSTRAINT %s PRIMARY KEY (%s)',
            $constraint->getName(),
            $columns
        );
    }
1229411
public function checkConstraint($constraint)
    {
        if (!$constraint instanceof ConstraintContract && !$constraint instanceof ConstraintGroupContract) {
            throw new InvalidArgumentException("Constraint has to be Constraint or ConstraintGroup, not " . Type::of($constraint));
        }
        if ($this->allowedOperators && $constraint instanceof Constraint) {
            $constraint->allowOperators($this->allowedOperators);
        }
        return $constraint;
    }
238470
public function find($constraints, $columns = '*', ...$loaders)
    {
    	if (! is_array($constraints)) {
            $constraints = ['id' => $constraints];
        }

        //We fetch the user using a given constraint.
        $model = $this->getModel()->select($columns)->where($constraints)->get();

        //We throw an exception if the user was not found to avoid whether
        //somebody tries to look for a non-existent user.
        abort_if( ! $model, 404);

        //If loaders were requested, we will lazy load them.
        if (count($loaders) > 0) {
            $model->load(implode(',', $loaders));
        }

        return $model;
    }
804556
public function resolve(Constraint $constraint, FormInterface $form, RuleCollection $collection)
    {
        /** @var \Symfony\Component\Validator\Constraints\AbstractComparison $constraint */
        $constraintClass = get_class($constraint);
        if ($constraintClass === LessThan::class) {
            $rule = new ConstraintRule(
                self::RULE_NAME,
                $constraint->value - 1, // TODO support floats
                new RuleMessage($constraint->message, array('{{ compared_value }}' => $constraint->value)),
                $constraint->groups
            );
        } elseif ($constraintClass === LessThanOrEqual::class) {
            $rule = new ConstraintRule(
                self::RULE_NAME,
                $constraint->value,
                new RuleMessage($constraint->message, array('{{ compared_value }}' => $constraint->value)),
                $constraint->groups
            );
        }
        /** @var Range $constraint */
        elseif ($constraintClass === Range::class && $constraint->max !== null) {
            $rule = new ConstraintRule(
                self::RULE_NAME,
                $constraint->max,
                new RuleMessage($constraint->maxMessage, array('{{ limit }}' => $constraint->max)),
                $constraint->groups
            );
        } else {
            throw new LogicException();
        }

        $collection->set(
            self::RULE_NAME,
            $rule
        );
    }
387642
public function setColumns($columns, $size = null)
    {
        if (is_null($size)) {
            $size = $this->baseSize;
        }
        $columnAttribute = $size . 'Columns';
        $this->{$columnAttribute} = $columns;
    }
162104
protected function validateDelimiter(Constraint $constraint)
    {
        if (strlen($constraint->delimiter) > 2) {
            throw new ConstraintDefinitionException(sprintf('"%s" is not a valid delimiter', $constraint->delimiter));
        }
    }
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()]
                );
            }
        }
    }