laraorvite/eloquent-wildcard-validator
最新稳定版本:1.0
Composer 安装命令:
composer require laraorvite/eloquent-wildcard-validator
包简介
Fixes ErrorException: Indirect modification of overloaded property in Laravel nested validation.
README 文档
README
This package fixes the ErrorException: Indirect modification of overloaded property that occurs in Laravel when performing wildcard validation on nested data structures containing Eloquent models or objects with magic methods.
The Problem
In Laravel core, when you validate nested data using wildcards (e.g., tickets.*.people.*.email), the validator attempts to initialize missing data. If the data contains Eloquent models, PHP throws an error because magic methods (__get and __set) do not support indirect modification by reference.
The Solution
This package transparently extends the Laravel Validator to ensure that all data is safely converted to a plain array (arrayified) before validation begins, preventing any illegal modification of model properties while preserving the original data integrity.
Installation
You can install the package via composer:
composer require laraorvite/eloquent-wildcard-validator
The package will automatically register its Service Provider.
Usage
No additional configuration is required. Use the Laravel Validator facade or $request->validate() as you normally would:
$data = [ 'orders' => Order::with('items')->get() ]; $request->validate([ 'orders.*.items.*.price' => 'required|numeric' ]);
Credits
- LaraOrVite
- Special thanks to the Laravel community.
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-13