laravel 自定义验证

 $messages = [
'name.integer' => '名字不能为整型',
'name.max' => '长度不能超过5',
]; public static $rules=[
'name' => 'required|integer|max:5|foo_fei', //foo_fei 自定义验证
'score' => 'required|integer',
]; Validator::extend('foo_fei', function ($attribute, $value, $parameters) { //exit('进来了');
return $value=='foo';
//这里的错误消息在 resources/lang/en/validation.php
// 'custom' => [
// 'attribute-name' => [
// 'rule-name' => 'custom-message',
// ],
// 'name'=> [
// 'foo_fei'=>'你是傻逼'
// ],
// ],
}); $validatedData = Validator::make($data,Student::$rules,$messages);
05-11 20:56