Skip to content

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

@sbouchard-spordle

Description

@sbouchard-spordle

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix them

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions