CodeIgniter4: Bug: [Validation] `required_without` will not work if the field is specified with asterisk

See https://github.com/codeigniter4/CodeIgniter4/issues/5922#issuecomment-1113904559

The following test fails. The validation passes.

    public function testRequireWithoutWithWildCard()
    {
        $data = [
            'a' => [
                ['b' => 1, 'c' => 2],
                ['c' => ''],
            ],
        ];

        $this->validation->setRules([
            'a.*.c' => 'required_without[a.*.b]',
        ])->run($data);

        $this->assertSame(
            'The a.*.c field is required when a.*.b is not present.',
            $this->validation->getError('a.1.c')
        );
    }

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 26 (26 by maintainers)

Most upvoted comments

Ok, I got it. I will close my PR then modify the code logic to support the #5922 use case.