I'm trying to implement this example. It looks so simple to implement but I have some troubles.
@Get('test')
async test(
@Query('size', new DefaultValuePipe(10), ParseIntPipe) size: number,
@Query('page', new DefaultValuePipe(1), ParseIntPipe) page: number,
) {
// Do some stuff
}
- The first request I've made is
http://localhost/api/test- The requests I sent without params are replied with
400 Bad Requestand the message isValidation failed (numeric string is expected).
- The requests I sent without params are replied with
- The second request I've made is
http://localhost/api/test?size=&page=- The requests I sent with empty params are passed as
0, not with the value that I want to be provided by default.
- The requests I sent with empty params are passed as
In both requests, the default values are expected to pass, right? If so, what am I doing wrong?