除非验证程序,否则无法使用必需的



在我的应用程序中,我试图使用required_excess验证器,但每次我碰到控制器时都会抛出错误;

Method IlluminateValidationValidator::validateRequiredUnless,meta.app,pos does not exist.

这就是轨迹:

Message
Method IlluminateValidationValidator::validateRequiredUnless,meta.app,pos does not exist.
Level
ERROR
Exception
```{
"class": "BadMethodCallException",
"message": "Method Illuminate\Validation\Validator::validateRequiredUnless,meta.app,pos does not exist.",
"code": 0,
"file": "/var/app/current/vendor/laravel/framework/src/Illuminate/Validation/Validator.php:1146",
"trace": [
"/var/app/current/vendor/laravel/framework/src/Illuminate/Validation/Validator.php:365",
"/var/app/current/vendor/laravel/framework/src/Illuminate/Validation/Validator.php:268",
"/var/app/current/vendor/laravel/framework/src/Illuminate/Validation/Validator.php:293",
"/var/app/current/app/Http/Controllers/Shared/CheckoutController.php:76",
"{"function":"checkout","class":"App\\Http\\Controllers\\Shared\\CheckoutController","type":"->","args":["[object] (Illuminate\\Http\\Request)"]}",
"/var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54",
"/var/app/current/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:45",
"/var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Route.php:212",
"/var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Route.php:169",
"/var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Router.php:665",
"/var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:30",
"/var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php:41",
"/var/app/current/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151",
"/var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php:53",
"/var/app/current/vendor/laravel/framework/src/Illuminate/Routing/Middleware/ThrottleRequests.php:57",
"/va…

这是我的验证码:

$rules = [
"client" => "required_unless,meta.app,pos",
"customer" => "required",
"customer.fullname" => "required|min:4",
"customer.phone" => "required|numeric",
"customer.email" => "email|required_unless,meta.app,pos",
"payment" => "required",
"payment.type" => "required",
"items" => "required",
"items.*.id" => "required",
"items.*.quantity" => "required_if:meta.type,==,event|numeric",
"items.*.seat" => "required_if:meta.type,==,food",
"meta" => "required",
"meta.type" => "required",
"meta.timestamp" => "required",
"meta.token" => "required_unless,meta.app,pos"
];
$validator = Validator::make($request->all(), $rules, []);
// Validate incoming request
if ($validator->fails()) {
return response($validator->errors(), 400);
}

required_unless之后应该是:而不是,

required_unless:anotherfield,value,

尝试required_unless:meta.app,pos

相关内容

  • 没有找到相关文章

最新更新