respect-validation/tests/integration/issue-1244.phpt
Henrique Moody 8573bc5d45
Do not overwrite "IDs" when updating names
When you have a chain of rules in the Validation and overwrite the name
with "setName()," it's impossible to get the messages from all rules in
the chain as an array because they all have the same name.

These changes will change that behavior by creating a more explicit
distinction between "IDs" and "names." The "IDs" will remain
unchangeable, while we can always overwrite the names. That means that
the array messages will look more similar to the chain, and it will be
possible to overwrite the messages from multiple rules in the same
chain.

Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2024-03-26 01:12:44 +01:00

16 lines
288 B
PHP

--FILE--
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
use Respect\Validation\Validator as v;
exceptionMessages(static fn () => v::key('firstname', v::notBlank()->setName('First Name'))->assert([]));
?>
--EXPECTF--
[
'firstname' => 'First Name must be present',
]