getInvalidMessage example


    private function modelToNorm(mixed $value): mixed
    {
        try {
            foreach ($this->config->getModelTransformers() as $transformer) {
                $value = $transformer->transform($value);
            }
        } catch (TransformationFailedException $exception) {
            throw new TransformationFailedException(sprintf('Unable to transform data for property path "%s": ', $this->getPropertyPath()).$exception->getMessage()$exception->getCode()$exception$exception->getInvalidMessage()$exception->getInvalidMessageParameters());
        }

        return $value;
    }

    /** * Reverse transforms a value if a model transformer is set. * * @throws TransformationFailedException If the value cannot be transformed to "model" format */
    private function normToModel(mixed $value): mixed
    {
            // lead to duplicate errors if error bubbling is enabled on the             // child.             // See also https://github.com/symfony/symfony/issues/4359             if ($childrenSynchronized) {
                $clientDataAsString = \is_scalar($form->getViewData())
                    ? (string) $form->getViewData()
                    : get_debug_type($form->getViewData());

                $failure = $form->getTransformationFailure();

                $this->context->setConstraint($formConstraint);
                $this->context->buildViolation($failure->getInvalidMessage() ?? $config->getOption('invalid_message'))
                    ->setParameters(array_replace(
                        ['{{ value }}' => $clientDataAsString],
                        $config->getOption('invalid_message_parameters'),
                        $failure->getInvalidMessageParameters()
                    ))
                    ->setInvalidValue($form->getViewData())
                    ->setCode(Form::NOT_SYNCHRONIZED_ERROR)
                    ->setCause($failure)
                    ->addViolation();
            }
        }

        
Home | Imprint | This part of the site doesn't use cookies.