yiisoft / validator

Yii validator library
https://www.yiiframework.com/
BSD 3-Clause "New" or "Revised" License
112 stars 39 forks source link

`Composite` + `Nested` combination shows incorrect message for `Required` #565

Open arogachev opened 1 year ago

arogachev commented 1 year ago

Similar to #556.

$rule = new class () extends Composite {
    public function getRules(): array
    {
        return [
            new Nested([
                'name' => [new Required(), new Length(min: 1)],
            ]),
        ];
    }
};
$result = (new Validator())->validate([], $rule);
$errors = $result->getErrorMessagesIndexedByPath();

Expected:

[
    'name' => [
        'Value not passed.',
        'The value must be a string.',
    ],
],

Actual:

[
    'name' => [
        'Value cannot be blank.',
        'The value must be a string.',
    ],
],