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 permit_empty does no work together with required_with and required_without #2953

Closed
najdanovicivan opened this issue May 8, 2020 · 1 comment · Fixed by #2957
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@najdanovicivan
Copy link
Contributor

najdanovicivan commented May 8, 2020

Describe the bug
I'm working on admin form for MythAuth where user password can be changed. The form also updated other user data. So requirement for changing password is to enter current password in cases where password is not being changed it should be possible to submit the form with empty current password so I have validation rules it the following format

'currentPassword'=>'permit_empty|required_with[newPassword]|valid_password[{id}]'

This makes validation pass when currentPassword is empty and newPassword is set which should not be possible

CodeIgniter 4 version
git - 85cd56a

Affected module(s)
Validation Library

Expected behaviour, and steps to reproduce if appropriate
If newPassword is not empty validation should not pass with empty currentPassword field.

Context

  • OS: MacOS 10.15.4
  • Web server Apache 2
  • PHP version 7.4.2
@najdanovicivan najdanovicivan added the bug Verified issues on the current code behavior or pull requests that will fix them label May 8, 2020
@crustamet
Copy link
Contributor

crustamet commented May 10, 2020

Dude your modification works with other rules like ?

permit_empty|uploaded[image]|is_image[image]

I have tested your modification with CI 4.0.3
and it is like skipping the entire rule set.

So it is skipping the entire rule set without your modifications aswell.

Your modifications to this rule is not working correctly.

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