docs/messages/placeholder-conversion.md
Messages in Validation have placeholders between {{ and }} characters. To replace these placeholders with real parameter values, we need to convert them to strings.
This conversion is handled by PlaceholderFormatter from Respect\StringFormatter, which uses Respect\Stringifier to convert values into their string representations.
You can add custom modifiers by providing a custom PlaceholderFormatter to the
ContainerRegistry:
use DI\Container;
use Respect\StringFormatter\Modifier;
use Respect\StringFormatter\PlaceholderFormatter;
use Respect\Validation\ContainerRegistry;
use function DI\factory;
ContainerRegistry::setContainer(
ContainerRegistry::createContainer([
PlaceholderFormatter::class => factory(
fn(Container $container) => new PlaceholderFormatter(
[],
new MyCustomModifier($container->get(Modifier::class)),
),
),
])
);
See PlaceholderFormatter documentation for more information on creating custom modifiers and the configuration section for more details on container setup.