@param string $name
@param array  $constraints

@return ValidationPropertyMappingBuilderInterface
9180
public static function create(string $name, array $constraints): ValidationPropertyMappingBuilderInterface
    {
        $self = new self();
        $self->name = $name;

        $self->constraints = [];
        foreach ($constraints as $constraint) {
            $self->addConstraint($constraint);
        }

        return $self;
    }
238559
public function visitHostnameFormatConstraint(StringValue\HostnameFormatConstraint $constraint)
    {
        if (!$this->formatValidationEnabled()) {
            return $this->createResult();
        }

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

        return $this->createSingleIssueResult($constraint);
    }
83858
public static function createFromConstraintViolationList(ConstraintViolationListInterface $errors)
    {
        $exception = static::createUnprocessable('Input validation errors.');

        /** @var ConstraintViolationInterface $error */
        foreach ($errors as $error) {
            $exception->errorValidation($error->getPropertyPath(), $error->getMessage());
        }

        return $exception;
    }
22688
public function custom($name) {
        if ($this->_exist) {
            $class = 'Controller\Request\Custom\\' . ucfirst($name);

            if (class_exists($class)) {
                array_push($this->_constraints, ['type' => self::CUSTOM, 'value' => new $class($this->_field, $this->_label, $this->_data[$this->_field])]);
            }
            else {
                throw new MissingClassException('The custom validation class "' . $class . '" was not found');
            }
        }

        return $this;
    }
388052
public function setConstraintClass($name, $class)
    {
        // Ensure class exists
        if (!class_exists($class)) {
            throw new InvalidArgumentException('Unknown constraint ' . $name);
        }
        // Ensure class is appropriate
        if (!in_array('JsonSchema\Constraints\ConstraintInterface', class_implements($class))) {
            throw new InvalidArgumentException('Invalid class ' . $name);
        }
        $this->constraintMap[$name] = $class;

        return $this;
    }
716331
public function validate($entity, Constraint $constraint)
    {
        if (!$entity instanceof ClientDetails) {
            throw new \InvalidArgumentException('Expected instance of ClientDetails');
        }
        
        $username = $entity->getUsername();
        $result   = $this->clientRepository->findOneBy(['clientDetails.username' => $username]);
        
        if (null === $result) {
            return;
        }
        
        if ($this->context instanceof ExecutionContextInterface) {
            $this->context
                ->buildViolation($constraint->message)
                ->setParameter('{{ url }}', $this->routerHelper->generateUrl('front.client.login'))
                ->atPath('username')
                ->setInvalidValue($username)
                ->addViolation();
        }
    }
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;
	}
1223903
public function getColumnIndex($name)
    {
        if (!\is_array($this->mappingColumns)) {
            $this->mappingColumns = [];

            /* @var BlockInterface $column */
            foreach ($this->getColumns() as $i => $column) {
                $this->mappingColumns[$column->getName()] = $i;
            }
        }

        if (isset($this->mappingColumns[$name])) {
            $column = $this->columns[$this->mappingColumns[$name]];

            return $column->getOption('index');
        }

        throw new InvalidArgumentException(sprintf('The column name "%s" does not exist', $name));
    }
525538
public static function create($name, $type, array $rules = [])
    {
        if (false === ValidatorType::isSupported($type)) {
            throw new ValidatorFactoryException(
                \sprintf('The provided validator type \'%s\' is not supported.', $type)
            );
        }


        $validator = self::createValidator($name, $type);

        return self::applyValidatorRules($validator, $rules);
    }
612906
protected function _constraint($name, $value, $schema = null) {
		$value += ['options' => []];
		$meta = isset($this->_constraints[$name]) ? $this->_constraints[$name] : null;
		$template = isset($meta['template']) ? $meta['template'] : null;
		if (!$template) {
			return;
		}

		$data = [];
		foreach ($value as $name => $value) {
			switch ($name) {
				case 'key':
				case 'index':
					if (isset($meta[$name])) {
						$data['index'] = $meta[$name];
					}
				break;
				case 'to':
					$data[$name] = $this->name($value);
				break;
				case 'on':
					$data[$name] = "ON {$value}";
				break;
				case 'expr':
					if (is_array($value)) {
						$result = [];
						$context = new Query(['type' => 'none']);
						foreach ($value as $key => $val) {
							$return = $this->_processConditions($key, $val, $context, $schema);
							if ($return) {
								$result[] = $return;
							}
						}
						$data[$name] = join(" AND ", $result);
					} else {
						$data[$name] = $value;
					}
				break;
				case 'toColumn':
				case 'column':
					$data[$name] = join(', ', array_map([$this, 'name'], (array) $value));
				break;
			}
		}

		return trim(Text::insert($template, $data, ['clean' => true]));
	}
846360
public function apply($constraints) : Builder
	{
		if ($constraints && $this->type == 'product_categories') {
			return $this->builder->whereIn('category_id', $constraints);
		}

		if ($constraints && is_array($constraints)) {
			return $this->filterByConstraints($constraints);
		}

		return $this->builder;
	}
651778
public function getInstance(Constraint $constraint)
    {
        $name = $constraint->validatedBy();

        if (!isset($this->validators[$name])) {
            if ($this->container->has($name)) {
                $this->validators[$name] = $this->container->get($name);
            } else {
                if (!class_exists($name)) {
                    throw new ValidatorException(sprintf('Constraint validator "%s" does not exist or is not enabled. Check the "validatedBy" method in your constraint class "%s".', $name, \get_class($constraint)));
                }

                $this->validators[$name] = new $name();
            }
        }

        if (!$this->validators[$name] instanceof ConstraintValidatorInterface) {
            throw new UnexpectedTypeException($this->validators[$name], ConstraintValidatorInterface::class);
        }

        return $this->validators[$name];
    }
251563
public function getConstraint($fieldName, $constraintName)
    {
        if (isset($this->constraints[$fieldName][$constraintName])) {
            return $this->constraints[$fieldName][$constraintName];
        }
    }
990128
public static function createEmbedOne(string $name): NormalizationFieldMappingBuilderInterface
    {
        $self = new self($name);
        $self->fieldNormalizer = new EmbedOneFieldNormalizer(new PropertyAccessor($name));

        return $self;
    }
341808
private function validate(array $data, array $constraints, $parentPath = '')
    {
        if (is_numeric(key($constraints))) {
            $subConstrains = reset($constraints);
            $length = count($data);
            /** @noinspection ForeachInvariantsInspection */
            for ($i = 0; $i < $length; $i++) {
                $this->validate($data[$i], $subConstrains, $parentPath . '[' . $i . ']');
            }
        } else {
            foreach ($constraints as $key => $subConstrains) {
                if (!array_key_exists($key, $data)) {
                    throw new \InvalidArgumentException(
                        sprintf('Missing key %s[%s]', $parentPath, $key)
                    );
                }
                if ($subConstrains) {
                    $this->validate($data[$key], $subConstrains, $parentPath . '[' . $key . ']');
                }
            }
        }
    }
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;
        }
    }
1253651
public function validate(array $constraints, $data, $prettyName = 'This value')
    {
        if (isset($constraints['callback'])) {     
            call_user_func_array($constraints['callback'], array($data, $prettyName));
        }
    }