Add a single constraint violation to a partially-built array of errors
in the format described in `groupViolationsByField`

@param array                        $errors    Array of errors
@param ConstraintViolationInterface $violation Violation to add
15409
protected function addViolationToOutput(array $errors, ConstraintViolationInterface $violation)
    {
        $path = $this->getPropertyPathAsArray($violation);

        // Drill into errors and find where the error message should be added, building nonexistent portions of the path
        $currentPointer = &$errors;

        while (count($path) > 0) {
            $currentField = array_shift($path);

            if (! array_key_exists($currentField, $currentPointer) or ! is_array($currentPointer[$currentField])) {
                $currentPointer[$currentField] = [];
            }

            if (is_numeric($currentField)) {
                for ($i = 0; $i < (int) $currentField; $i++) {
                    if (! array_key_exists($i, $currentPointer)) {
                        $currentPointer[(int) $i] = null;
                    }
                }

                // Sort the elements of this array so JsonResponse converts this to an array rather than an object
                ksort($currentPointer);
            }

            $currentPointer = &$currentPointer[$currentField];
        }

        $currentPointer[] = $violation->getMessage();

        return $errors;
    }
114946
public function isViolationFiltered(Violation $violation)
    {
        foreach ($this->violationFilters as $violationFilter) {
            if (true === $violationFilter->isViolationFiltered($violation)) {
                return true;
            }
        }

        return false;
    }
79959
public function validate($value, Constraint $constraint)
    {
        /**@var $constraint CodeUnit */
        if (!in_array($value, $this->codes)) {
            $this->context->buildViolation($constraint->message)
                ->setParameter('{{ value }}', $value)
                ->addViolation();
        }
    }
1204542
public function addErrors(array $errors = [])
    {
        foreach ($errors as $attribute => $error) {
            if (is_array($error)) {
                foreach ($error as $e) {
                    $this->addError($attribute, $e);
                }
            } else {
                $this->addError($attribute, $error);
            }
        }
    }
192346
public static function addResourceError(ResourceInterface $resource, $message, \Exception $e = null): void
    {
        $resource->setStatus(ResourceStatutes::ERROR);
        $resource->getErrors()->add(new ConstraintViolation($message, $message, [], $resource->getRealData(), null, null, null, null, null, $e));
    }
102116
private function buildMessage(ConstraintViolationListInterface $violations)
    {
        $msg = '';
        $errors = [];
        $childrenErrors = [];

        /* @var ConstraintViolationInterface $violation */
        foreach ($violations as $violation) {
            if (null === $violation->getPropertyPath()) {
                $errors[] = $violation->getMessage();
            } else {
                $childrenErrors[$violation->getPropertyPath()][] = $violation->getMessage();
            }
        }

        $msg = $this->buildGlobalErrors($errors, $msg);
        $msg = $this->buildChildrenErrors($childrenErrors, $msg);

        return $msg;
    }
1340371
private function importErrors(array $errors): void
    {
        foreach ($errors as $field => $errors) {
            foreach ($errors as $message) {
                $this->addError($message, $field);
            }
        }
    }
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();
        }
    }
1286141
public function validate($value, Constraint $constraint)
    {
        if (! $value instanceof MethodDescriptor
            && ! $value instanceof FunctionDescriptor
        ) {
            throw new ConstraintDefinitionException(
                'The Functions\AreAllArgumentsValid validator may only be used on function or method objects'
            );
        }

        $this->constraint = $constraint;

        $this->initValueObject($value);

        $violation = $this->processArgumentValidation();
        if ($violation) {
            return $violation;
        }

        $this->checkParamsExists();
    }
836641
protected void violation(final Receiver<Void> receiver,
      final Set<ConstraintViolation<?>> errors) {
    this.reuse();
    Set<Throwable> causes = null;
    for (final AbstractRequest<?, ?> request : new ArrayList<>(this.state.invocations)) {
      try {
        request.onViolation(errors);
      } catch (final Throwable t) {
        if (causes == null) {
          causes = new HashSet<>();
        }
        causes.add(t);
      }
    }
    if (receiver != null) {
      try {
        receiver.onConstraintViolation(errors);
      } catch (final Throwable t) {
        if (causes == null) {
          causes = new HashSet<>();
        }
        causes.add(t);
      }
    }

    if (causes != null) {
      throw new UmbrellaException(causes);
    }
  }
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);
        }
    }
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;
    }
637065
public function addConstraint(Constraint $constraint) : void
    {
        $constraint->setValidator($this);
        array_push($this->constraints, $constraint);
    }
162104
protected function validateDelimiter(Constraint $constraint)
    {
        if (strlen($constraint->delimiter) > 2) {
            throw new ConstraintDefinitionException(sprintf('"%s" is not a valid delimiter', $constraint->delimiter));
        }
    }
500348
protected function addViolation($value, Constraint $constraint)
    {
        $this->context->buildViolation($constraint->message)
            ->setParameter('%field%', null)
            ->setParameter('%value%', $value)
            ->addViolation()
        ;

        return true;
    }
565490
public function add($key, Constraint\ConstraintInterface $constraint)
    {
        if (empty($this->constraints[$key])) {
            $this->constraints[$key] = [];
        }
        $this->constraints[$key][] = $constraint;

        return $this;
    }
922460
public void checkExpectedValidationViolations(
			Set<ConstraintViolation<T>> violations,
			List<String> expectedValidationViolations) {

		if (violations != null && expectedValidationViolations != null) {

			List<String> givenViolations = new ArrayList<String>();
			for (ConstraintViolation<T> violation : violations) {
				givenViolations.add(violation.getMessageTemplate());
			}

			checkViolations(givenViolations, expectedValidationViolations);
		}

	}