nestjs/nest · error · BadRequestException
Validation failed
Error message
Validation failed
What it means
Error "Validation failed" thrown in nestjs/nest.
Source
Thrown at sample/10-fastify/src/common/pipes/parse-int.pipe.ts:9
import { BadRequestException } from '@nestjs/common';
import { PipeTransform, Injectable, ArgumentMetadata } from '@nestjs/common';
@Injectable()
export class ParseIntPipe implements PipeTransform<string> {
async transform(value: string, metadata: ArgumentMetadata) {
const val = parseInt(value, 10);
if (isNaN(val)) {
throw new BadRequestException('Validation failed');
}
return val;
}
}
View on GitHub (pinned to 6ec0e2783d)
Solutions
- Send a numeric value for the :id route parameter; the parse-int pipe rejects non-numeric input.
- Fix the client request URL to include an integer id.
- If arbitrary string ids are allowed, drop the ParseIntPipe from the parameter.
Example fix
// client: GET /cats/42
@Get(':id')
findOne(@Param('id', ParseIntPipe) id: number) {} When it happens
Trigger: Thrown at sample/10-fastify/src/common/pipes/parse-int.pipe.ts:9 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of nestjs/nest@6ec0e2783d (2026-08-03).
Data as JSON: /data/errors/c4b2403bcdea6ed2.json.
Report an issue: GitHub.