mirror of
https://github.com/Respect/Validation.git
synced 2024-06-01 05:12:50 +02:00
Move "Message placeholder conversion" documentation
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
parent
5c0bd3a5da
commit
408d8e825b
|
@ -228,26 +228,6 @@ Array
|
|||
Note that `getMessage()` will only return a message when the specific validation
|
||||
in the chain fails.
|
||||
|
||||
## Message placeholder conversion
|
||||
|
||||
Message in Validation usually have placeholders that are in between "{{" and
|
||||
"}}" characters. To replace those placeholders with the real parameters, we need
|
||||
to convert them to string.
|
||||
|
||||
We use the `ParameterStringifier` to convert those parameters into a string.
|
||||
Our default implementation will convert all parameters with
|
||||
[Respect\Stringifier](https://github.com/Respect/Stringifier) unless the
|
||||
parameter is called `name` and it is already a string.
|
||||
|
||||
It is possible to overwrite that behavior by creating a custom implementation of
|
||||
the `ParameterStringifier` and passing it to the `Factory`:
|
||||
|
||||
```php
|
||||
Factory::setDefaultInstance(
|
||||
(new Factory())->withParameterStringifier(new MyCustomStringifier())
|
||||
);
|
||||
```
|
||||
|
||||
## Validator name
|
||||
|
||||
On `v::attribute()` and `v::key()`, `{{name}}` is the attribute/key name. For others,
|
||||
|
|
19
docs/message-placeholder-conversion.md
Normal file
19
docs/message-placeholder-conversion.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
## Message placeholder conversion
|
||||
|
||||
Messages in Validation usually have placeholders that are in between "{{" and
|
||||
"}}" characters. To replace those placeholders with the real parameters, we need
|
||||
to convert them to string.
|
||||
|
||||
We use the `ParameterStringifier` to convert those parameters into a string.
|
||||
Our default implementation will convert all parameters with
|
||||
[Respect\Stringifier](https://github.com/Respect/Stringifier) unless the
|
||||
parameter is called `name` and it is already a string.
|
||||
|
||||
It is possible to overwrite that behavior by creating a custom implementation of
|
||||
the `ParameterStringifier` and passing it to the `Factory`:
|
||||
|
||||
```php
|
||||
Factory::setDefaultInstance(
|
||||
(new Factory())->withParameterStringifier(new MyCustomStringifier())
|
||||
);
|
||||
```
|
Loading…
Reference in a new issue