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

fix: TypeError in Validation is_unique/is_not_unique #7085

Merged
merged 8 commits into from
Jan 12, 2023

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented Jan 11, 2023

Description
See https://forum.codeigniter.com/showthread.php?tid=86107

  • fix TypeError in Rules::is_unique() and is_not_unique() in Strict Rules
  • refactor tests
    • move the test logic to StrictRules\DatabaseRelatedRulesTest because Strict Rules are now default

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

TypeError : CodeIgniter\Validation\Rules::is_unique(): Argument #1 ($str) must be of type ?string, int given, called in /.../CodeIgniter4/system/Validation/StrictRules/Rules.php on line 154
 /.../CodeIgniter4/system/Validation/Rules.php:126
If we use Strict Rules, the behavior may change.
@kenjis kenjis added the bug Verified issues on the current code behavior or pull requests that will fix them label Jan 11, 2023
@kenjis kenjis changed the title Fix validtaion is unique fix: TypeError in Validtaion is_unique/is_not_unique Jan 11, 2023
@kenjis kenjis added the 4.3 label Jan 11, 2023
@kenjis kenjis changed the title fix: TypeError in Validtaion is_unique/is_not_unique fix: TypeError in Validation is_unique/is_not_unique Jan 11, 2023
@jlopes90
Copy link

I already tested it and it works.

@@ -86,7 +86,11 @@ public function greater_than_equal_to(?string $str, string $min): bool
public function is_not_unique(?string $str, string $field, array $data): bool
Copy link

@jlopes90 jlopes90 Jan 11, 2023

Choose a reason for hiding this comment

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

Yesterday I was trying something else, I removed "?string" and it worked.

@jlopes90
Copy link

jlopes90 commented Jan 11, 2023

I'm using "codeigniter 4 app starter", how to get this to update or change this branch to vendor/codeigniter4/framework or something?

I tested it was to copy the files and replace.

@kenjis
Copy link
Member Author

kenjis commented Jan 12, 2023

@jlopes90 Thank you for testing.

See codeigniter4/shield#195 (comment)
This is an example in Shield, but all you need to do is

  1. add the repository URL in repositories
  2. change the version to the branch (dev-fix-Validtaion-is_unique in this case)

@kenjis kenjis merged commit 1f8a3f0 into codeigniter4:develop Jan 12, 2023
@kenjis kenjis deleted the fix-Validtaion-is_unique branch January 12, 2023 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.3 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.

None yet

4 participants