Skip to content

fix: [Validation] if_exist does not work with array data#8959

Merged
kenjis merged 3 commits into
codeigniter4:developfrom
kenjis:fix-if_exist-with-array
Jun 19, 2024
Merged

fix: [Validation] if_exist does not work with array data#8959
kenjis merged 3 commits into
codeigniter4:developfrom
kenjis:fix-if_exist-with-array

Conversation

@kenjis

@kenjis kenjis commented Jun 12, 2024

Copy link
Copy Markdown
Member

Description
Fixes #8956

Fixed the bug that If an array is passed, Validation with if_exist rule always returns true.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@kenjis kenjis added the bug Verified issues on the current code behavior or pull requests that will fix them label Jun 12, 2024
@kenjis kenjis force-pushed the fix-if_exist-with-array branch from 76118c6 to 83c15b2 Compare June 12, 2024 01:34
Comment thread system/Validation/FormatRules.php Outdated
Comment on lines +32 to +35
if (is_array($str)) {
return false;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this check only added here? Shouldn't it also be in other rules?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because there was an error when running phpunit.
But changing alpha is not good.

The Traditional Rules should not be changed as much as possible.
So I reverted it and changed the test code.

Traditional Rules exist only for backward compatibility. Do not use them in new projects. Even if you are already using them, we recommend switching to Strict Rules.
https://codeigniter4.github.io/CodeIgniter4/libraries/validation.html#traditional-rules

@kenjis kenjis force-pushed the fix-if_exist-with-array branch from 83c15b2 to 1ca24da Compare June 12, 2024 22:56
@kenjis kenjis merged commit 2fae945 into codeigniter4:develop Jun 19, 2024
@kenjis kenjis deleted the fix-if_exist-with-array branch June 19, 2024 02:15
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 this pull request may close these issues.

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

2 participants