Laravel Version
11.x
PHP Version
8.4.4
Database Driver & Version
No response
Description
The current code in ValidationRuleParser explodeExplicitRule function does not handles the explode for multiple chained non-nested Date or Numeric Rule objects. It falls into the condtion that checks if the rule is an object and wraps the rule in an array as a string cast without exploding it at the pipe symbol.
protected function explodeExplicitRule($rule, $attribute)
{
if (is_string($rule)) {
return explode('|', $rule);
}
if (is_object($rule)) {
// The bug lies here, prepareRule falls to a return of (string) $rule
return Arr::wrap($this->prepareRule($rule, $attribute));
}
$rules = [];
foreach ($rule as $value) {
if ($value instanceof Date || $value instanceof Numeric) {
$rules = array_merge($rules, explode('|', (string) $value));
} else {
$rules[] = $this->prepareRule($value, $attribute);
}
}
return $rules;
}
Steps To Reproduce
A simple validation like the following is failing
$rules = [
'date' => Rule::date()->format('Y-m-d'),
];