Skip to content
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] if_exist is not working as intended with arrays #8956

Closed
sbouchard-spordle opened this issue Jun 11, 2024 · 1 comment · Fixed by #8959
Closed

Bug: [Validation] if_exist is not working as intended with arrays #8956

sbouchard-spordle opened this issue Jun 11, 2024 · 1 comment · Fixed by #8959
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@sbouchard-spordle
Copy link

sbouchard-spordle commented Jun 11, 2024

PHP Version

8.2

CodeIgniter4 Version

4.4.8

CodeIgniter4 Installation Method

Composer (using codeigniter4/appstarter)

Which operating systems have you tested for this bug?

Linux

Which server did you use?

apache

Database

No response

What happened?

Ok so based on the official CodeIgniter 4's documentation, the if_exist validation rule is supposed to prevent further validation when the field is not present in the data to validate.

However, I noticed that when sending an array it causes the if_exist to misbehave.

Steps to Reproduce

To reproduce you can use this bit of code:

$validation_rules = [
    'foo' => [
        'rules' => 'if_exist|in_list',
        'errors' => [
            'in_list' => 'invalid_parameter'
        ]
     ]
 ];
 $this->validate($validation_rules);

and send something like this in the payload (This is from Postman's Body using form-data):

foo[0]:bar

Expected Output

The validate() function should return false

Anything else?

No response

@sbouchard-spordle sbouchard-spordle added the bug Verified issues on the current code behavior or pull requests that will fix them label Jun 11, 2024
@kenjis kenjis changed the title Bug: if_exist is not working as intended with arrays Bug: [Validation] if_exist is not working as intended with arrays Jun 12, 2024
@kenjis
Copy link
Member

kenjis commented Jun 12, 2024

Check #8959

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants