@param ConstraintViolationListInterface $errors

@throws ValidationException
@SuppressWarnings(PHPMD.StaticAccess)
496112
private function throwExceptionIfErrors(ConstraintViolationListInterface $errors): void
    {
        if (0 === $errors->count()) {
            return;
        }
        throw ValidationException::create($errors, $this->dataObject);
    }
560087
public function createViolationErrorResponse(ViolationListException $exception)
    {
        $errorData = [];

        /** @var \Symfony\Component\Validator\ConstraintViolationInterface $violation */
        foreach ($exception->getViolationList() as $violation) {
            $errorData[$violation->getPropertyPath()] = $violation->getMessage();
        }

        // Try get code from errors storage via exception
        $errors = $this->handler->getErrors();
        $code = $errors->hasException($exception) ? $errors->getExceptionCode($exception) : 0;

        return $this->createErrorResponse($code, null, $errorData);
    }
383952
public function validate ($entity, Constraint $constraint)
    {
        if (!$entity instanceof ClientBillingAddressInterface) {
            throw new \InvalidArgumentException('Expected instance of ClientBillingAddressInterface');
        }
        
        if (false === $entity->isCompanyAddress()) {
            return;
        }
        
        if ($this->context instanceof ExecutionContextInterface) {
            
            if (false === $this->isValidCompanyName($entity)) {
                $this->context->buildViolation('client.company_name_not_valid')->atPath('companyName')->addViolation();
            }
            
            if (false === $this->isValidVatId($entity)) {
                $this->context->buildViolation('client.vatid_not_valid')->atPath('vatId')->addViolation();
            }
        }
    }
196832
public function validate($value, Constraint $constraint)
  {
    $valid = false;
    foreach ($constraint->format as $format)
    {
      $date = \DateTime::createFromFormat($format, $value);
      if ($date instanceof \DateTime)
      {
        $valid = true;
        break;
      }
    }
    if ($valid === false)
    {
      $this->context->addViolation($constraint->message, array('%invalid%' => $value));
    }
  }
442079
public function validate($location, Constraint $constraint)
    {
        if (null === $location) {
            $this->context->addViolation($constraint->message);

            return;
        }

        $isContainer = new IsContainer();
        if (!$isContainer->isSatisfiedBy($location)) {
            $this->context->addViolation($constraint->message);
        }
    }
1363580
public function resolve(Constraint $constraint, FormInterface $form, RuleCollection $collection)
    {
        $constraintClass = get_class($constraint);

        /** @var \Symfony\Component\Validator\Constraints\AbstractComparison $constraint */
        if ($constraintClass === GreaterThan::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 === GreaterThanOrEqual::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->min !== null) {
            $rule = new ConstraintRule(
                self::RULE_NAME,
                $constraint->min,
                new RuleMessage($constraint->minMessage, array('{{ limit }}' => $constraint->min)),
                $constraint->groups
            );
        } else {
            throw new LogicException();
        }

        $collection->set(
            self::RULE_NAME,
            $rule
        );
    }
32824
private function createMessage(ConstraintViolationListInterface $list, $line)
    {
        $messages = [];
        foreach ($list as $violation) {
            $messages[] = $violation->getMessage();
        }

        return sprintf('Line %d: %s', $line, implode(', ', $messages));
    }
576289
protected function isValid(&$value): ConstraintInterface
    {
        if ($this->constraintsSet instanceof ConstraintsSetInterface) {
            $this->constraintsSet->isValid($value);
        }

        return $this;
    }
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()]
                );
            }
        }
    }
666898
public function validate($value, Constraint $constraint)
    {
        /** @var EntityExists $constraint */
        if ($constraint->validate($value)) {
            $this->context->addViolation(
                $constraint->message,
                [
                    '{{ type }}' => $constraint->entityClass,
                    '{{ value }}' => $value,
                ]
            );
        }
    }
637065
public function addConstraint(Constraint $constraint) : void
    {
        $constraint->setValidator($this);
        array_push($this->constraints, $constraint);
    }
350271
public function validate(
        ConstraintInterface $constraint,
        Value\ConcreteValueInterface &$value,
        PointerInterface $entryPoint = null
    ) {
        if (null === $entryPoint) {
            $entryPoint = new Pointer;
        }

        $this->clear();

        $this->pushContext(array($value, $entryPoint));
        $result = $constraint->accept($this);

        $this->clear();

        return $result;
    }
860830
public function validate($value, Constraint $constraint): void
    {
        // Build a list of values.
        $item_values = [];
        foreach ($value as $item) {
            $item_value = $this->property_accessor->getValue($item, $constraint->property);

            // If any value is repeated build a violation.
            if (isset($item_values[$item_value])) {
                $this->context->buildViolation($constraint->message)
                    ->setParameter('{{ string }}', $constraint->property)
                    ->addViolation();
            }
            $item_values[$item_value] = true;
        }
    }
370606
public function validate($value, Constraint $constraint)
    {
        if (!$this->workflowRegistry instanceof Registry) {
            throw new Exception('Can not validate model: No workflows were defined');
        }

        if (!$constraint instanceof Model) {
            throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Model');
        }

        if (null === $value || '' === $value) {
            return;
        }

        if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
            throw new UnexpectedTypeException($value, 'string');
        }

        try {
            WorkflowHelper::get($this->workflowRegistry, $value);
        } catch (InvalidArgumentException $exception) {
            $this->context->buildViolation($constraint->message)
                ->setParameter('{{ string }}', $value)
                ->addViolation();
        }
    }
690079
private static void check(Set<ConstraintViolation<Object>> constraintViolations) {
        Iterator<ConstraintViolation<Object>> iterator = constraintViolations.iterator();
        if (iterator.hasNext()) {
            throw new ValidationException(iterator.next().getMessage());
        }
    }
872042
public function logValidationError($validationType, $messageException = null, $method = null, $line = null)
    {
        if (self::getConfig('log', 'validation')) {
            $this->logMessage("VALIDATE][KO][{$validationType}", "{$messageException} --- " . $this->__toString() . "\n", $method, $line);
        }
        //file_put_contents('php://stderr', "[" . date('Y-m-d H:i:s') . "][VALIDATION][KO][{{$method}#{$line}][{$validationType}] : {$messageException} --- " . $this->__toString() . "\n");
    }
645109
protected void processConstraintViolation(final Set<ConstraintViolation<Object>> violations,
            final SheetBindingErrors<?> errors) {
        
        for(ConstraintViolation<Object> violation : violations) {
            
            final String fieldName = violation.getPropertyPath().toString();
            final Optional<FieldError> fieldError = errors.getFirstFieldError(fieldName);
            
            if(fieldError.isPresent() && fieldError.get().isConversionFailure()) {
                // 型変換エラーが既存のエラーにある場合は、処理をスキップする。
                continue;
            }
            
            final ConstraintDescriptor<?> cd = violation.getConstraintDescriptor();
            
            /*
             * エラーメッセージのコードは、後から再変換できるよう、BeanValidationの形式のエラーコードも付けておく。
             */
            final String[] errorCodes = new String[]{
                    cd.getAnnotation().annotationType().getSimpleName(),
                    cd.getAnnotation().annotationType().getCanonicalName(),
                    cd.getAnnotation().annotationType().getCanonicalName() + ".message"
                    };
            
            final Map<String, Object> errorVars = createVariableForConstraint(cd);
            
            final String nestedPath = errors.buildFieldPath(fieldName);
            if(Utils.isEmpty(nestedPath)) {
                // オブジェクトエラーの場合
                errors.createGlobalError(errorCodes)
                    .variables(errorVars)
                    .defaultMessage(violation.getMessage())
                    .buildAndAddError();
                
            } else {
                // フィールドエラーの場合
                
                // 親のオブジェクトから、セルの座標を取得する
                final Object parentObj = violation.getLeafBean();
                final Path path = violation.getPropertyPath();
                Optional<CellPosition> cellAddress = Optional.empty();
                Optional<String> label = Optional.empty();
                if(path instanceof PathImpl) {
                    final PathImpl pathImpl = (PathImpl) path;
                    cellAddress = new PositionGetterFactory().create(parentObj.getClass(), pathImpl.getLeafNode().getName())
                            .map(getter -> getter.get(parentObj)).orElse(Optional.empty());
                    
                    label = new LabelGetterFactory().create(parentObj.getClass(), pathImpl.getLeafNode().getName())
                            .map(getter -> getter.get(parentObj)).orElse(Optional.empty());
                    
                }
                
                // フィールドフォーマッタ
                Class<?> fieldType = errors.getFieldType(nestedPath);
                if(fieldType != null) {
                    FieldFormatter<?> fieldFormatter = errors.findFieldFormatter(nestedPath, fieldType);
                    if(fieldFormatter != null) {
                        errorVars.putIfAbsent("fieldFormatter", fieldFormatter);
                    }
                }
                
                // 実際の値を取得する
                errorVars.putIfAbsent("validatedValue", violation.getInvalidValue());
                
                errors.createFieldError(fieldName, errorCodes)
                    .variables(errorVars)
                    .address(cellAddress)
                    .label(label)
                    .defaultMessage(violation.getMessage())
                    .buildAndAddError();
                
            }
            
        }
        
    }