@param Generic\EnumConstraint $constraint

@return string
349575
public function visitEnumConstraint(Generic\EnumConstraint $constraint)
    {
        $enumValues = array();
        foreach ($constraint->values() as $enumValue) {
            $enumValues[] = var_export($enumValue->value(), true);
        }

        if (count($enumValues) < 2) {
            return sprintf(
                'The value must be equal to %s.',
                array_pop($enumValues)
            );
        }

        return sprintf(
            'The value must be equal to one of the following: %s.',
            implode(', ', $enumValues)
        );
    }
530279
public function visitIpv6AddressFormatConstraint(StringValue\Ipv6AddressFormatConstraint $constraint)
    {
        if (!$this->formatValidationEnabled()) {
            return $this->createResult();
        }

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

        return $this->createSingleIssueResult($constraint);
    }
1216579
public function visitTypeConstraint(Generic\TypeConstraint $constraint)
    {
        $valueTypes = array_map(function (ValueType $valueType) {
            return var_export($valueType->value(), true);
        }, $constraint->valueTypes());

        if (count($valueTypes) < 2) {
            return sprintf(
                'The value must be of type %s.',
                array_pop($valueTypes)
            );
        }

        return sprintf(
            'The value must be one of the following types: %s.',
            implode(', ', $valueTypes)
        );
    }
92146
protected function nameAndParameters($constraint)
    {
        if (!strpos($constraint, ':')) {
            return [$this->normalizeConstraintName($constraint), []];
        }

        list($name, $parameters) = explode(':', $constraint, 2);

        return [$this->normalizeConstraintName($name), explode(',', $parameters)];
    }
578332
private function getStringType(Constraint $constraint) : ?string
    {
        $stringType = null;
        if (null !== ($typeFromPayload = $this->constraintPayloadDocHelper->getTypeIfExist($constraint))) {
            $stringType = $typeFromPayload;
        } elseif ($constraint instanceof Assert\Type) {
            $stringType = strtolower($constraint->type);
        } elseif ($constraint instanceof Assert\IdenticalTo) {// Strict comparison so value define the type
            $stringType = gettype($constraint->value);
        }

        return $stringType;
    }
896248
public function visitIpv4AddressFormatConstraint(StringValue\Ipv4AddressFormatConstraint $constraint)
    {
        if (!$this->formatValidationEnabled()) {
            return $this->createResult();
        }

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

        return $this->createSingleIssueResult($constraint);
    }
405079
public function visitTypeConstraint(Generic\TypeConstraint $constraint)
    {
        $value = $this->currentValue();
        $isValid = false;
        foreach ($constraint->valueTypes() as $valueType) {
            if ($valueType === Value\ValueType::ARRAY_TYPE()) {
                $isValid = $value instanceof Value\ArrayValue;
            } elseif ($valueType === Value\ValueType::BOOLEAN_TYPE()) {
                $isValid = $value instanceof Value\BooleanValue;
            } elseif ($valueType === Value\ValueType::DATE_TIME_TYPE()) {
                $isValid = $value instanceof Value\DateTimeValue;
            } elseif ($valueType === Value\ValueType::INTEGER_TYPE()) {
                $isValid = $value instanceof Value\IntegerValue;
            } elseif ($valueType === Value\ValueType::NULL_TYPE()) {
                $isValid = $value instanceof Value\NullValue;
            } elseif ($valueType === Value\ValueType::NUMBER_TYPE()) {
                $isValid = $value instanceof Value\NumberValueInterface;
            } elseif ($valueType === Value\ValueType::OBJECT_TYPE()) {
                $isValid = $value instanceof Value\ObjectValue;
            } elseif ($valueType === Value\ValueType::STRING_TYPE()) {
                $isValid = $value instanceof Value\StringValue;
            }

            if ($isValid) {
                return $this->createResult();
            }
        }

        return $this->createSingleIssueResult($constraint);
    }
238377
private function getTypeFromCallbackConstraint(Assert\Callback $constraint): TypeDoc
    {
        $callbackResult = call_user_func($constraint->callback);
        $doc = $this->guess(
            is_array($callbackResult)
                ? $callbackResult
                : [$callbackResult]
        );
        return $doc;
    }
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;
        }
    }
24894
public function visitPropertiesConstraint(ObjectValue\PropertiesConstraint $constraint)
    {
        return new ObjectValue\PropertiesConstraint(
            $this->transformConstraintArray($constraint->schemas()),
            $this->transformConstraintArray($constraint->patternSchemas()),
            $constraint->additionalSchema()->accept($this)
        );
    }
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;
    }
59093
public static function fromString($constraintExpression)
    {
        if (!preg_match('/^(==?|\!=?|~|[<>]=?)?((?:\*|[0-9]+)(?:.(?:\*|[0-9]+))*)(?:\@(\w+))?$/', $constraintExpression, $m)) {
            throw new \InvalidArgumentException("Constraint expression '$constraintExpression' could not be parsed");
        }
        return new self(
            !empty($m[1]) ? $m[1] : '=',
            $m[2],
            !empty($m[3]) ? $m[3] : 'stable'
        );
    }
1144087
public function validate($value, Constraint $constraint)
    {
        if ($value === null) {
            return;
        }

        $chunks = \explode('.', (string) $value);
        if (\count($chunks) > 2) {
            throw new \Exception('Number can have only 1 "." character.');
        }

        $precision = \strlen(\implode('', $chunks));
        $scale = isset($chunks[1]) ? \strlen($chunks[1]) : 0;

        if ($constraint->precision !== null && $precision > $constraint->precision) {
            $this->context->addViolation($constraint->precisionMessage, [
                '%maxPrecision%' => $constraint->precision,
            ]);
        }

        if ($constraint->scale !== null && $scale > $constraint->scale) {
            $this->context->addViolation($constraint->scaleMessage, [
                '%maxScale%' => $constraint->scale,
            ]);
        }
    }
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);
        }
    }
1083640
public function getConstrainedKeys($constraint)
	{
		$this->related->select($this->relatedKey);

		return $this->getConstrained($constraint)->fieldsByKey($this->relatedKey);
	}
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();
            }
        }
    }
42447
private function createDocFromConstraint(Constraint $constraint) : ?TypeDoc
    {
        $doc = null;

        if (null !== ($stringType = $this->getStringType($constraint))) {
            $doc = $this->normalizeType($stringType);
        } elseif ($constraint instanceof Assert\Callback) {
            $doc = $this->getTypeFromCallbackConstraint($constraint);
        } elseif ($constraint instanceof Assert\Existence && count($constraint->constraints) > 0) {
            $doc = $this->guess($constraint->constraints);
        }

        return $doc;
    }