Skip to content

Commit 964fe71

Browse files
committed
test: add test for validation error with asterisk field.
1 parent 574feb7 commit 964fe71

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/system/Validation/ValidationTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,28 @@ public function testRunGroupWithCustomErrorMessage(): void
463463
], $this->validation->getErrors());
464464
}
465465

466+
/**
467+
* @see https://github.com/codeigniter4/CodeIgniter4/issues/6245
468+
*/
469+
public function testRunWithCustomErrorsAndAsteriskField(): void
470+
{
471+
$data = [
472+
'foo' => [
473+
['bar' => null],
474+
['bar' => null],
475+
]
476+
];
477+
$this->validation->setRules(
478+
['foo.*.bar' => ['label' => 'foo bar', 'rules' => 'required']],
479+
['foo.*.bar' => ['required' => 'Required']]
480+
);
481+
$this->validation->run($data);
482+
$this->assertSame([
483+
'foo.0.bar' => 'Required',
484+
'foo.1.bar' => 'Required'
485+
], $this->validation->getErrors());
486+
}
487+
466488
/**
467489
* @dataProvider rulesSetupProvider
468490
*

0 commit comments

Comments
 (0)