Skip to content

Comments

[12.x] Fix Validator::appendRules() with pipe-separated rule strings#58304

Merged
taylorotwell merged 2 commits intolaravel:12.xfrom
leo108:12.x
Jan 7, 2026
Merged

[12.x] Fix Validator::appendRules() with pipe-separated rule strings#58304
taylorotwell merged 2 commits intolaravel:12.xfrom
leo108:12.x

Conversation

@leo108
Copy link
Contributor

@leo108 leo108 commented Jan 7, 2026

Summary

Fixes a bug where Validator::appendRules() throws exception when new rules use pipe-separated strings (e.g., 'required|string|min:5'). The issue occurs because array_merge_recursive() merges already-parsed arrays with unparsed strings.

Step to reproduce

When using appendRules() with pipe-separated rules:

$validator = new Validator($trans, ['name' => 'ab'], ['name' => 'required']);
$validator->appendRules(['name' => 'string|min:5']);
$validator->fails(); // Throws: Method validateString|min does not exist

Solution

Modified Validator::appendRules() to pre-process the new rules by exploding pipe-separated strings into arrays before calling array_merge_recursive().

@taylorotwell taylorotwell merged commit e839b63 into laravel:12.x Jan 7, 2026
70 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants