Merged
Conversation
Contributor
|
Json不是一种参数类型,不应该与Get Post同等吧 |
Contributor
Author
|
就算不等同,也应该有办法检测一下吧。。。我们公司这边POST全部都是json的,这样一来,就没办法使用HttpValidator了。。。 |
Contributor
|
这个直接改一下参数提供的部分就好了,Content-Type为json情况下,提供对应的数据参数 |
Contributor
Author
|
@huangzhhui 能具体说明一下么。。不是很明白 |
Contributor
|
在POST模式下,如果 |
Contributor
|
增加Json层级数据验证 /**
* @RequestMapping("string")
*
* @Strings(from=ValidatorFrom::POST, name="user.name", min=3, max=10, default="Tom")
* @Strings(from=ValidatorFrom::POST, name="text", min=3, max=11, default="text")
*
* @param string $name
* @param Request $request
*
* @return array
*/
public function string(Request $request, string $name)
{
return [
$request->json('user.name'),
$request->json('text'),
];
}Request Body: {
"user": {
"name": "Swoft"
},
"text": "This's text"
} |
Contributor
Author
|
👍 |
huangzhhui
pushed a commit
to swoft-cloud/swoft-http-message
that referenced
this pull request
Jul 15, 2018
* 增加Json Validator支持 * 当content-type为json时,重置$post的数据,进行验证 * get json value by dot notation for validator
huangzhhui
pushed a commit
to swoft-cloud/swoft-http-server
that referenced
this pull request
Jul 15, 2018
* 增加Json Validator支持 * 当content-type为json时,重置$post的数据,进行验证 * get json value by dot notation for validator
swoft-bot
added a commit
that referenced
this pull request
Oct 15, 2018
218abf7 Update Request.php (#184) b20adb8 修复Json Validator会失效的BUG (#153) 68b8332 fix stripos() expects parameter 1 to be string, array given (#140) 31e4eb9 fix: cannot correctly detect json request (#135) 6be72b3 Validator增加Json格式支持 (#122) c9e871d add coWrite(); use swoft/swoole-ide-helper (#83) c989bfe add server params git-subtree-dir: src/http-message git-subtree-split: 218abf7ed6ecc16ae7ba3a3d61e1fc6d67caa1b9
swoft-bot
pushed a commit
to swoft-cloud/swoft-view
that referenced
this pull request
Jan 25, 2019
* 增加Json Validator支持 * 当content-type为json时,重置$post的数据,进行验证 * get json value by dot notation for validator
stelin
pushed a commit
to swoft-cloud/swoft-http-message
that referenced
this pull request
May 28, 2019
* 增加Json Validator支持 * 当content-type为json时,重置$post的数据,进行验证 * get json value by dot notation for validator
stelin
pushed a commit
to swoft-cloud/swoft-http-server
that referenced
this pull request
May 28, 2019
* 增加Json Validator支持 * 当content-type为json时,重置$post的数据,进行验证 * get json value by dot notation for validator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.