Skip to content

Latest commit

 

History

History
38 lines (29 loc) · 1.5 KB

File metadata and controls

38 lines (29 loc) · 1.5 KB

Message placeholder conversion

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.

Custom modifiers

You can add custom modifiers by providing a custom PlaceholderFormatter to the ContainerRegistry:

use Respect\Config\Container;
use Respect\StringFormatter\Modifier;
use Respect\StringFormatter\PlaceholderFormatter;
use Respect\Validation\ContainerRegistry;

ContainerRegistry::setContainer(
    ContainerRegistry::createContainer([
        PlaceholderFormatter::class => static 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.