nestjs/nest · error · BadRequestException
Validation failed
Error message
Validation failed
What it means
Error "Validation failed" thrown in nestjs/nest.
Source
Thrown at sample/01-cats-app/src/common/pipes/parse-int.pipe.ts:13
import {
ArgumentMetadata,
BadRequestException,
Injectable,
PipeTransform,
} 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; ParseIntPipe rejects non-numeric input.
- Fix the client request URL (e.g. /cats/1 instead of /cats/abc).
- If non-numeric ids are valid, replace ParseIntPipe with a custom pipe that handles them.
Example fix
// client: GET /cats/42 (not /cats/abc)
@Get(':id')
findOne(@Param('id', ParseIntPipe) id: number) {} When it happens
Trigger: Thrown at sample/01-cats-app/src/common/pipes/parse-int.pipe.ts:13 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/23a9a5eda7869329.json.
Report an issue: GitHub.