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

Method explodeExplicitRule working wrong with regex rule #45520

Closed
du-nong-0070 opened this issue Jan 5, 2023 · 4 comments · Fixed by #45555
Closed

Method explodeExplicitRule working wrong with regex rule #45520

du-nong-0070 opened this issue Jan 5, 2023 · 4 comments · Fixed by #45555
Labels

Comments

@du-nong-0070
Copy link

du-nong-0070 commented Jan 5, 2023

  • Laravel Version: 9.45.1
  • PHP Version: 8.1.13
  • Database Driver & Version:

Description:

Method explodeExplicitRule works wrong with this rule regex:/^[\d\-]*$/|max:20.

It can not explodes this rule to two patterns like

[
   0 => 'regex:/^[\d\-]*$/',
   1 => 'max:20'
]

I have verified it in Laravel 8 and It has worked perfectly.
I saw Laravel 9 had changed explodeExplicitRule which made it wrong.
In another rule like required|regex:/^[\d\-]*$/|max:20 or just rotate it like max:20|regex:/^[\d\-]*$/,
It works perfectly.

https://github.com/laravel/framework/blob/9.x/src/Illuminate/Validation/ValidationRuleParser.php#L86-L103

https://github.com/laravel/framework/blob/8.x/src/Illuminate/Validation/ValidationRuleParser.php#L84-L93

Steps To Reproduce:

use Laravel validator with rule regex:/^[\d\-]*$/|max:20

@du-nong-0070 du-nong-0070 changed the title Method explodeExplicitRule working wrong regex rule Method explodeExplicitRule working wrong with regex rule Jan 5, 2023
@driesvints
Copy link
Member

Ping @stevebauman. Seems to be because of the changes made here? #40941

@du-nong-028 can you confirm that reverting that PR fixes your issue?

@stevebauman
Copy link
Contributor

Thanks for the ping @driesvints! Looking into this now.

@du-nong-0070
Copy link
Author

du-nong-0070 commented Jan 6, 2023

@driesvints Thank you, I confirm that It's working when I revert that PR #40941
@stevebauman FYI
Current

array:1 [▼
  "tel" => array:1 [▶
    0 => "regex:/^[\d\-]*$/|max:20"
  ]
]

When reverting that PR

array:1 [▼
  "tel" => array:2 [▶
    0 => "regex:/^[\d\-]*$/"
    1 => "max:20"
  ]
]

@stevebauman
Copy link
Contributor

Thanks @du-nong-028, I appreciate the detail in your report 🙏 . I've submitted a PR that reverts the changes and restores documented behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants