private function inputToNorm($value, string $path)
    {
        if (null === $this->inputTransformer) {
            $this->inputTransformer = $this->fieldConfig->getNormTransformer() ?? false;
        }

        if (false === $this->inputTransformer) {
            if (null !== $value && !is_scalar($value)) {
                $e = new \RuntimeException(
                    sprintf(
                        'Norm value of type %s is not a scalar value or null and not cannot be '.
                        'converted to a string. You must set a NormTransformer for field "%s" with type "%s".',
                        \gettype($value),
                        $this->fieldConfig->getName(),
                        \get_class($this->fieldConfig->getType()->getInnerType())
                    )
                );

                $error = new ConditionErrorMessage(
                    $path,
                    $this->fieldConfig->getOption('invalid_message', $e->getMessage()),
                    $this->fieldConfig->getOption('invalid_message', $e->getMessage()),
                    $this->fieldConfig->getOption('invalid_message_parameters', []),
                    null,
                    $e
                );

                $this->addError($error);

                return null;
            }

            return '' === $value ? null : $value;
        }

        try {
            return $this->inputTransformer->reverseTransform($value);
        } catch (TransformationFailedException $e) {
            $error = new ConditionErrorMessage(
                $path,
                $this->fieldConfig->getOption('invalid_message', $e->getMessage()),
                $this->fieldConfig->getOption('invalid_message', $e->getMessage()),
                $this->fieldConfig->getOption('invalid_message_parameters', []),
                null,
                $e
            );

            $this->addError($error);

            return null;
        }
    }
private function inputToNorm($value, string $path)
    {
        if (null === $this->inputTransformer) {
            $this->inputTransformer = $this->fieldConfig->getNormTransformer() ?? false;
        }

        if (false === $this->inputTransformer) {
            if (null !== $value && !is_scalar($value)) {
                $e = new \RuntimeException(
                    sprintf(
                        'Norm value of type %s is not a scalar value or null and not cannot be '.
                        'converted to a string. You must set a NormTransformer for field "%s" with type "%s".',
                        \gettype($value),
                        $this->fieldConfig->getName(),
                        \get_class($this->fieldConfig->getType()->getInnerType())
                    )
                );

                $error = new ConditionErrorMessage(
                    $path,
                    $this->fieldConfig->getOption('invalid_message', $e->getMessage()),
                    $this->fieldConfig->getOption('invalid_message', $e->getMessage()),
                    $this->fieldConfig->getOption('invalid_message_parameters', []),
                    null,
                    $e
                );

                $this->addError($error);

                return null;
            }

            return '' === $value ? null : $value;
        }

        try {
            return $this->inputTransformer->reverseTransform($value);
        } catch (TransformationFailedException $e) {
            $error = new ConditionErrorMessage(
                $path,
                $this->fieldConfig->getOption('invalid_message', $e->getMessage()),
                $this->fieldConfig->getOption('invalid_message', $e->getMessage()),
                $this->fieldConfig->getOption('invalid_message_parameters', []),
                null,
                $e
            );

            $this->addError($error);

            return null;
        }
    }
private function inputToNorm ( $ value , string $ path ) { if ( null === $ this -> inputTransformer ) { $ this -> inputTransformer = $ this -> fieldConfig -> getNormTransformer ( ) ?? false ; } if ( false === $ this -> inputTransformer ) { if ( null !== $ value && ! is_scalar ( $ value ) ) { $ e = new \ RuntimeException ( sprintf ( 'Norm value of type %s is not a scalar value or null and not cannot be ' . 'converted to a string. You must set a NormTransformer for field "%s" with type "%s".' , \ gettype ( $ value ) , $ this -> fieldConfig -> getName ( ) , \ get_class ( $ this -> fieldConfig -> getType ( ) -> getInnerType ( ) ) ) ) ; $ error = new ConditionErrorMessage ( $ path , $ this -> fieldConfig -> getOption ( 'invalid_message' , $ e -> getMessage ( ) ) , $ this -> fieldConfig -> getOption ( 'invalid_message' , $ e -> getMessage ( ) ) , $ this -> fieldConfig -> getOption ( 'invalid_message_parameters' , [ ] ) , null , $ e ) ; $ this -> addError ( $ error ) ; return null ; } return '' === $ value ? null : $ value ; } try { return $ this -> inputTransformer -> reverseTransform ( $ value ) ; } catch ( TransformationFailedException $ e ) { $ error = new ConditionErrorMessage ( $ path , $ this -> fieldConfig -> getOption ( 'invalid_message' , $ e -> getMessage ( ) ) , $ this -> fieldConfig -> getOption ( 'invalid_message' , $ e -> getMessage ( ) ) , $ this -> fieldConfig -> getOption ( 'invalid_message_parameters' , [ ] ) , null , $ e ) ; $ this -> addError ( $ error ) ; return null ; } }
Reverse transforms a value if a value transformer is set.

@param mixed $value

@return mixed returns null when the value is empty or invalid.
Note: When the value is invalid an error is registered
Reverse transforms a value if a value transformer is set .