driftingly / rector-laravel

Rector upgrades rules for Laravel
http://getrector.org
MIT License
529 stars 51 forks source link

Validation Rule string value to Array #183

Closed peterfox closed 7 months ago

peterfox commented 7 months ago

Changes

Why

It would be neat to automatically configure validation rules that are in the single string format to become arrays.

e.g.

 Validator::make($data, [
-    'field' => 'required|nullable|string|max:255',
+    'field' => ['required', 'nullable', 'string', 'max:255'],
 ]);

This rule will also work with the Validator facade and classes that extend the FormRequest class and have a rules method.