framework
framework copied to clipboard
Method explodeExplicitRule working wrong with regex rule
- 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
Ping @stevebauman. Seems to be because of the changes made here? https://github.com/laravel/framework/pull/40941
@du-nong-028 can you confirm that reverting that PR fixes your issue?
Thanks for the ping @driesvints! Looking into this now.
@driesvints Thank you, I confirm that It's working when I revert that PR https://github.com/laravel/framework/pull/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"
]
]
Thanks @du-nong-028, I appreciate the detail in your report 🙏 . I've submitted a PR that reverts the changes and restores documented behaviour.