添加请求参数验证

main
gzydong 2021-01-04 17:37:14 +08:00
parent c185008896
commit a3caf5c56f
3 changed files with 10 additions and 10 deletions

View File

@ -128,7 +128,7 @@ class ArticleController extends CController
$params = $this->request->inputs(['class_id', 'class_name']); $params = $this->request->inputs(['class_id', 'class_name']);
$this->validate($params, [ $this->validate($params, [
'class_id' => 'required|integer', 'class_id' => 'required|integer',
'class_name' => 'required' 'class_name' => 'required|max:20'
]); ]);
$class_id = $this->articleService->editArticleClass($this->uid(), $params['class_id'], $params['class_name']); $class_id = $this->articleService->editArticleClass($this->uid(), $params['class_id'], $params['class_name']);
@ -218,7 +218,7 @@ class ArticleController extends CController
$params = $this->request->inputs(['tag_id', 'tag_name']); $params = $this->request->inputs(['tag_id', 'tag_name']);
$this->validate($params, [ $this->validate($params, [
'tag_id' => 'required|integer|min:0', 'tag_id' => 'required|integer|min:0',
'tag_name' => 'required' 'tag_name' => 'required|max:20'
]); ]);
$id = $this->articleService->editArticleTag($this->uid(), (int)$params['tag_id'], $params['tag_name']); $id = $this->articleService->editArticleTag($this->uid(), (int)$params['tag_id'], $params['tag_name']);

View File

@ -211,8 +211,8 @@ class GroupController extends CController
$params = $this->request->inputs(['group_id', 'group_name', 'group_profile', 'avatar']); $params = $this->request->inputs(['group_id', 'group_name', 'group_profile', 'avatar']);
$this->validate($params, [ $this->validate($params, [
'group_id' => 'required|integer', 'group_id' => 'required|integer',
'group_name' => 'required', 'group_name' => 'required|max:30',
'group_profile' => 'required', 'group_profile' => 'required|max:100',
'avatar' => 'present|url' 'avatar' => 'present|url'
]); ]);
@ -323,7 +323,7 @@ class GroupController extends CController
$params = $this->request->inputs(['group_id', 'visit_card']); $params = $this->request->inputs(['group_id', 'visit_card']);
$this->validate($params, [ $this->validate($params, [
'group_id' => 'required|integer', 'group_id' => 'required|integer',
'visit_card' => 'required' 'visit_card' => 'required|max:20'
]); ]);
$isTrue = UsersGroupMember::where('group_id', $params['group_id']) $isTrue = UsersGroupMember::where('group_id', $params['group_id'])
@ -432,7 +432,7 @@ class GroupController extends CController
$this->validate($params, [ $this->validate($params, [
'group_id' => 'required|integer', 'group_id' => 'required|integer',
'notice_id' => 'required|integer', 'notice_id' => 'required|integer',
'title' => 'required', 'title' => 'required|max:50',
'content' => 'required' 'content' => 'required'
]); ]);

View File

@ -240,8 +240,8 @@ class UsersController extends CController
{ {
$params = $this->request->inputs(['friend_id', 'remarks']); $params = $this->request->inputs(['friend_id', 'remarks']);
$this->validate($params, [ $this->validate($params, [
'friend_id' => 'required|integer', 'friend_id' => 'required|integer|min:1',
'remarks' => "required" 'remarks' => "required|max:20"
]); ]);
$user_id = $this->uid(); $user_id = $this->uid();
@ -265,7 +265,7 @@ class UsersController extends CController
$params = $this->request->inputs(['friend_id', 'remarks']); $params = $this->request->inputs(['friend_id', 'remarks']);
$this->validate($params, [ $this->validate($params, [
'friend_id' => 'required|integer', 'friend_id' => 'required|integer',
'remarks' => 'present' 'remarks' => 'present|max:50'
]); ]);
$user = $this->userService->findById($params['friend_id']); $user = $this->userService->findById($params['friend_id']);
@ -307,7 +307,7 @@ class UsersController extends CController
$params = $this->request->inputs(['apply_id', 'remarks']); $params = $this->request->inputs(['apply_id', 'remarks']);
$this->validate($params, [ $this->validate($params, [
'apply_id' => 'required|integer', 'apply_id' => 'required|integer',
'remarks' => 'present' 'remarks' => 'present|max:20'
]); ]);
$user_id = $this->uid(); $user_id = $this->uid();