Skip to content

Commit cf0aab1

Browse files
committed
test: add test for validation error with asterisk field.
1 parent 2a4b614 commit cf0aab1

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/system/Validation/StrictRules/ValidationTest.php

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

362+
/**
363+
* @see https://github.com/codeigniter4/CodeIgniter4/issues/6245
364+
*/
365+
public function testRunWithCustomErrorsAndAsteriskField(): void
366+
{
367+
$data = [
368+
'foo' => [
369+
['bar' => null],
370+
['bar' => null],
371+
],
372+
];
373+
$this->validation->setRules(
374+
['foo.*.bar' => ['label' => 'foo bar', 'rules' => 'required']],
375+
['foo.*.bar' => ['required' => 'Required']]
376+
);
377+
$this->validation->run($data);
378+
$this->assertSame([
379+
'foo.0.bar' => 'Required',
380+
'foo.1.bar' => 'Required',
381+
], $this->validation->getErrors());
382+
}
383+
362384
/**
363385
* @dataProvider rulesSetupProvider
364386
*

0 commit comments

Comments
 (0)