| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace App\Http\Validator;
- class LiveValidator extends BaseValidator
- {
- // 当前模型所有验证规则
- public static $rules = [
- 'id' => 'required',
- 'title' => 'required|max:200',
- 'description' => 'max:200',
- 'push_url' => 'required|max:200',
- 'play_url' => 'required:max:200',
- 'type' => 'required',
- ];
- // 当前模型所有错误提示信息
- public static $msgs = [
- 'required' => ':attribute不能为空',
- 'string' => ':attribute必须是字符串',
- 'min' => ':attribute长度不能小于:min位',
- 'max' => ':attribute长度不能大于:max位',
- 'exists' => ':attribute不存在',
- 'rule' => ':attribute格式不正确',
- ];
- // 当前模型所有验证字段
- public static $fields = [
- 'id' => 'ID',
- 'push_url' => '直播推流地址',
- 'play_url' => '直播播放地址',
- 'title' => '直播主题',
- 'description' => '直播内容',
- 'category' => '直播内容分类',
- 'type' => '直播类型',
- ];
- // 当前模型所有验证场景
- public static $scenes = [
- 'info'=> ['id'],
- 'create'=> ['description','push_url','play_url','category','type'],
- ];
- /**
- * 验证
- * @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);
- }
- }
|