mirror of
https://github.com/Respect/Validation.git
synced 2026-03-16 23:35:45 +01:00
Remove the setTemplate() method from Validator
The `setTemplate()` method can be confusing, as it can be tricky for someone to determine which chain is being templated. Using the `Templated` rule makes this much more explicit and adds a little bit of verbosity. For users, this will be a significant change, but there are easy ways to update this code in their projects, so I’m not overly concerned about it. Another benefit of this change is that it makes the `Validator` much simpler, as it no longer needs to track the template. This change also makes the `Reducer` simpler, for similar reasons to the `Validator`. However, because the `Validator` is simpler, we can remove the code that the `Reducer` had to meet the specific needs of the `Validator`.
This commit is contained in:
parent
8d08f47152
commit
d9380588e7
14 changed files with 63 additions and 147 deletions
|
|
@ -10,6 +10,6 @@ declare(strict_types=1);
|
|||
use Respect\Validation\Validator;
|
||||
|
||||
test('Scenario #1', catchMessage(function (): void {
|
||||
Validator::callback('is_int')->between(1, 2)->setTemplate('{{subject}} is not tasty')->assert('something');
|
||||
v::templated(Validator::callback('is_int')->between(1, 2), '{{subject}} is not tasty')->assert('something');
|
||||
},
|
||||
fn(string $message) => expect($message)->toBe('"something" is not tasty')));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue