ParseIntPipe is a built-in NestJS transformation pipe that converts a string parameter into a JavaScript integer. It is part of the Parse* family of pipes exported from @nestjs/common.
@Get(':id')
async findOne(@Param('id', ParseIntPipe) id: number) {
return this.catsService.findOne(id);
}If the string cannot be parsed, it throws a BadRequestException with status 400 before the route handler executes. Passing the class (not an instance) enables dependency injection; passing new ParseIntPipe({ errorHttpStatusCode: ... }) allows custom options.
Other Parse* pipes follow the same pattern: ParseFloatPipe, ParseBoolPipe, ParseArrayPipe, ParseUUIDPipe, ParseEnumPipe, ParseDatePipe, ParseFilePipe.