我正在尝试实现这个例子。看起来实现起来很简单,但我遇到了一些麻烦。
@Get('test')
async test(
@Query('size', new DefaultValuePipe(10), ParseIntPipe) size: number,
@Query('page', new DefaultValuePipe(1), ParseIntPipe) page: number,
) {
// Do some stuff
}
Run Code Online (Sandbox Code Playgroud)
http://localhost/api/test
400 Bad Request,消息为Validation failed (numeric string is expected)。http://localhost/api/test?size=&page=
0,而不是使用我希望默认提供的值。在这两个请求中,默认值都应该通过,对吧?如果是这样,我做错了什么?
| 归档时间: |
|
| 查看次数: |
2745 次 |
| 最近记录: |