@param Constraint $constraint

@return string
353185
public function getMessage($entity, $constraint)
    {
        $entityName = $entity->getRepository()->getEntityName();

        $message = $constraint->message;

        $classAnnotations = $this->getAnnotations('Class', $entityName);
        $labelAnnotation = array_filter($classAnnotations, function ($annotation) {
            return $annotation instanceof Label;
        });

        $labelTemp = null;
        if (is_array($labelAnnotation)) {
            $labelTemp = array_values($labelAnnotation);
        }

        $labelAnnotation = $labelTemp ? $labelTemp[0] : null;

        if ($labelAnnotation) {
            $message = str_replace('%entity%', ucfirst($labelAnnotation->value), $message);
        }

        /*
         * Campos para a validação informado na annotation
         */
        $fields = array_map('trim', $constraint->fields);
        foreach ($fields as $field) {
            $propertyAnnotations = $this->getAnnotations('Property', $entityName, $field);

            $labelAnnotation = array_filter($propertyAnnotations, function ($annotation) {
                return $annotation instanceof Label;
            });

            $labelTemp = null;
            if (is_array($labelAnnotation)) {
                $labelTemp = array_values($labelAnnotation);
            }

            $labelAnnotation = $labelTemp ? $labelTemp[0] : null;

            if ($labelAnnotation) {
                $message = str_replace('%'.$field.'%', ucfirst($labelAnnotation->value), $message);
            }
        }

        return $message;
    }
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;
    }
1083640
public function getConstrainedKeys($constraint)
	{
		$this->related->select($this->relatedKey);

		return $this->getConstrained($constraint)->fieldsByKey($this->relatedKey);
	}
401630
public function validate($value, Constraint $constraint)
    {
        if (null === $value || '' === $value) {
            return;
        }

        $value = (string) $value;
        $languages = $this->getLanguageNames();

        if (!array_key_exists($value,$languages)) {
            $this->context->addViolation($constraint->message, array('%string%' => $value));
        }
    }
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));
        }
    }
801976
public function validate($domainName, Constraint $constraint): void
    {
        if (null === $domainName) {
            return;
        }
        if (false === filter_var($domainName, FILTER_VALIDATE_DOMAIN)
            || false === \ts\stringContains($domainName, '.')
            || false !== \ts\stringContains($domainName, '//')
        ) {
            $this->context->buildViolation(sprintf(DomainName::MESSAGE, $this->formatValue($domainName)))
                          ->setParameter('{{ value }}', $this->formatValue($domainName))
                          ->setCode(DomainName::INVALID_DOMAIN_ERROR)
                          ->addViolation();
        }
    }
92146
protected function nameAndParameters($constraint)
    {
        if (!strpos($constraint, ':')) {
            return [$this->normalizeConstraintName($constraint), []];
        }

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

        return [$this->normalizeConstraintName($name), explode(',', $parameters)];
    }
1059138
protected function constraintFactory(string $constraint): ConstraintInterface
	{
		[$constraint, $parameters] = $this->parseFunction($constraint);

		if(!isset($this->constraints[$constraint]))
		{
			throw new RuntimeException(vsprintf('No constraint named [ %s ] has been registered.', [$constraint]));
		}

		$constraint = $this->container->get($this->constraints[$constraint], $parameters);

		return $constraint;
	}
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;
        }
    }
506146
protected function getPayloadDocValue(Constraint $constraint, string $documentationKey)
    {
        return $this->hasPayloadDocKey($constraint, $documentationKey)
            ? $constraint->payload[self::PAYLOAD_DOCUMENTATION_KEY][$documentationKey]
            : null
        ;
    }
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;
        }
    }
1066284
public static function normalize(Constraint $constraint)
    {
        return [
            'name'      => $constraint->getName(),
            'options'   => array_map(
                function (ConstraintOption $option) {
                    return [
                        'name'  => $option->getName(),
                        'value' => $option->getValue(),
                    ];
                },
                $constraint->getOptions()
            ),
        ];
    }
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();
            }
        }
    }
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
            );
    }
587881
public function visitMaximumLengthConstraint(StringValue\MaximumLengthConstraint $constraint)
    {
        $value = $this->currentValue();
        if (
            !$value instanceof Value\StringValue ||
            mb_strlen($value->value(), 'UTF-8') <= $constraint->maximum()
        ) {
            return $this->createResult();
        }

        return $this->createSingleIssueResult($constraint);
    }
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);
    }
674000
public function method($constraint)
    {
        $any = new \PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
        $expects = $this->expects($any);
        return call_user_func_array(array($expects, 'method'), func_get_args());
    }