laravel 方法 Illuminate\Validation\Validator::validateGt 不存在

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/50756180/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 17:48:09  来源:igfitidea点击:

Method Illuminate\Validation\Validator::validateGt does not exist

phplaravelvalidation

提问by reza

I have a set of validation rules in laravel. there are two date fields that one of them have to be greater than other. but when I use gt operator, an error apears:

我在 Laravel 中有一组验证规则。有两个日期字段,其中一个必须大于另一个。但是当我使用 gt 运算符时,会出现错误:

$validation =  Validator::make($request->all(), [
   'description'   => 'required|string',
   'started_at'    => 'required|date',
   'finished_at'   => 'required|date|gt:started_at',
]);

error is: Method Illuminate\Validation\Validator::validateGt does not exist.

错误是: Method Illuminate\Validation\Validator::validateGt does not exist.

回答by Davit

gt:started_atis wrong gtrule does not exist in laravel use after

gt:started_at是错误的 gt规则在 laravel 使用不存在

$validation =  Validator::make($request->all(), [
   'description'   => 'required|string',
   'started_at'    => 'required|date',
   'finished_at'   => 'required|date|after:started_at',
]);