Skip to content

Commit 2a751c6

Browse files
committed
test: add test case.
1 parent 2e62c82 commit 2a751c6

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

tests/system/Validation/ValidationTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,4 +1443,26 @@ public function testRuleWithLeadingAsterisk(): void
14431443
$this->assertFalse($this->validation->run($data));
14441444
$this->assertSame('Required *.foo', $this->validation->getError('*.foo'));
14451445
}
1446+
1447+
/**
1448+
* @see https://github.com/codeigniter4/CodeIgniter4/issues/5942
1449+
*/
1450+
public function testRequireWithoutWithWildCard()
1451+
{
1452+
$data = [
1453+
'a' => [
1454+
['b' => 1, 'c' => 2],
1455+
['c' => ''],
1456+
],
1457+
];
1458+
1459+
$this->validation->setRules([
1460+
'a.*.c' => 'required_without[a.*.b]',
1461+
])->run($data);
1462+
1463+
$this->assertSame(
1464+
'The a.*.c field is required when a.*.b is not present.',
1465+
$this->validation->getError('a.1.c')
1466+
);
1467+
}
14461468
}

0 commit comments

Comments
 (0)