-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: validation run even if required_with condition #7557
Comments
I'm not sure this is a bug or not. When you permit empty data, add the |
@kenjis |
|
|
I have to say I don't really understand the scenario OP is trying to solve here... |
The true issue is the following test cases pass. See #7562 (comment) /**
* @see https://github.com/codeigniter4/CodeIgniter4/issues/7557
*
* @dataProvider RequiredWithAndOtherRuleProvider
*/
public function testRequiredWithAndOtherRule(bool $expected, array $data): void
{
$this->validation->setRules([
'mustBeADate' => 'required_with[otherField]|permit_empty|valid_date',
]);
$result = $this->validation->run($data);
$this->assertSame($expected, $result);
}
public function RequiredWithAndOtherRuleProvider(): Generator
{
yield from [
[true, ['mustBeADate' => '']],
[true, ['mustBeADate' => null]],
[true, ['mustBeADate' => []]],
];
} |
Seems like we would need something like |
Yes, |
@shishamo I forgot we already have |
|
Yes, you're right. |
This is not a bug. How it works:
Note: In general, |
PHP Version
8.1
CodeIgniter4 Version
4.3.4
CodeIgniter4 Installation Method
Manual (zip or tar.gz)
Which operating systems have you tested for this bug?
macOS
Which server did you use?
apache
Database
PostgreSQL 15.2
What happened?
even if the field in the
required_with
condition does not exist the other validation rules runSteps to Reproduce
Expected Output
the validation rules should not run if the field required in the
required_with
condition does not exist?Anything else?
No response
The text was updated successfully, but these errors were encountered: