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: Validation of fields with a leading asterisk. #6243

Merged
merged 2 commits into from
Jul 9, 2022

Conversation

iRedds
Copy link
Collaborator

@iRedds iRedds commented Jul 8, 2022

Description
https://forum.codeigniter.com/showthread.php?tid=82391&pid=398147#pid398147

Fixed: Validation of fields with a leading asterisk (wildcard).
Also fixed getting an error by field name with a leading asterisk.

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

Copy link
Member

@MGatner MGatner left a comment

Choose a reason for hiding this comment

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

I'm not great with regex patterns but your test case looks good and nothing else failed so it's good by me. Thank you!

@MGatner
Copy link
Member

MGatner commented Jul 8, 2022

Original reporter verifies this works 💪

['foo' => null],
];

$this->validation->setRules(['*.foo' => 'required'], ['1.foo' => ['required' => 'Required {field}']]);
Copy link
Member

@kenjis kenjis Jul 9, 2022

Choose a reason for hiding this comment

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

This is not related with this bug, but ['1.foo' => ['required' => 'Required {field}']] seems tricky .
I would like to write ['*.foo' => ['required' => 'Required {field}']].

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You know, it turned out that the option you suggested does not work. The default error text is returned.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The error text will be defined for the *.foo field, and the 1.foo field is passed.

@kenjis kenjis merged commit bc688d9 into codeigniter4:develop Jul 9, 2022
@kenjis
Copy link
Member

kenjis commented Jul 9, 2022

Thank you! @iRedds

@iRedds iRedds deleted the fix/validation-leading-asterisk branch July 9, 2022 04:45
@kenjis kenjis added the bug Verified issues on the current code behavior or pull requests that will fix them label Jul 9, 2022
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.

4 participants