Spatie\LaravelData\Support\Validation\ValidationContext::__construct(): Argument #1 ($payload) must be of type ?array, string given, called in /var/www/application/vendor/spatie/laravel-data/src/Resolvers/DataValidationRulesResolver.php on line 204 #351
-
laravel-data version 3 is used. How to reproduce. Main DTO file
Nested Address DTO
The action in the controller looks like this
If we send a request with data like this
then there will be an error Yes, an address field in the request is wrong, it shouldn't be a string and should be an array, but if a client sent a string to a server, there is definitely should not be an error. In the laravel-data version 2 a rule "'address' => 'required|array:street,postcode,city'," applied and there would be a validation error like "The address must be an array" Shortly, it is not possible to work with nested objects, because if there is not an array for this object property in the request, then there will be a crash. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This should be fixed in the next release. |
Beta Was this translation helpful? Give feedback.
This should be fixed in the next release.