'required', 'coupon_give' => 'required|string|min:1|max:10', 'gd_name' => 'required|string|min:2|max:30', 'ws_name' => 'required|string|min:2|max:30', 'xy_content' => 'string|min:4|max:200', ]; // 当前模型所有错误提示信息 public static $msgs = [ 'required' => ':attribute不能为空', 'string' => ':attribute必须是字符串', 'min' => ':attribute长度不能小于:min位', 'max' => ':attribute长度不能大于:max位', 'exists' => ':attribute不存在', 'rule' => ':attribute格式不正确', ]; // 当前模型所有验证字段 public static $fields = [ 'id' => '活动ID', 'coupon' => '随喜券数', 'gd_name' => '功德主', 'ws_name' => '往生者', 'xy_content' => '心愿', ]; // 当前模型所有验证场景 public static $scenes = [ 'info'=> ['id'], 'books'=> ['id','gd_name','ws_name','xy_content'], ]; /** * 验证 * @param $request * @param string $scene * @return int|mixed */ public static function check($request, $scene=''){ $validator = new BaseValidator(self::$rules, self::$msgs, self::$fields, self::$scenes); return $validator->checkParams($request, $scene); } }