Nestjs validation failed (numeric string is expected). findBenutzerByID(id); with the following...
Nestjs validation failed (numeric string is expected). findBenutzerByID(id); with the following string: vorgesetzter?istVorgesetzter=true receiving the error you describe. , "123"). Nov 10, 2025 · A common challenge in NestJS DTO validation is the failure of string-to-number conversion when using the standard ValidationPipe({ transform: true }). This is how it goes. This is how express is implemented and NestJS follows the same behaviour: expressjs/express#2235, nestjs/nest#995 Sep 28, 2020 · So, if a validation for ParseIntPipe is failed, please return the passed message property back to the User. Apr 12, 2021 · Each query parameter comes as string, so it's not possible to validate numeric params correctly. Validation occurs later on. To fix this issue, I had to create a custom extension for ValidationPipe and use that instead of the plain validation pipe. benutzerService. Simple solution – use @Type() decorator from class-transformer library, and declare numeric field as Number. This typically occurs when incoming JSON payloads or URL query parameters supply numeric values as strings (e. g. Nov 30, 2019 · The reason for this error is that I had some dynamic routes that have ParseInt directives on them like /users/:id. So in short, the only thing that matters in route selection, is pattern, not validation set in it. Apr 26, 2020 · Currently right now if I call the endpoint without the limit query argument, the built in ParseIntPipe will throw a BadRequestException and return a bad request response to the user with the message Validation failed (numeric string is expected) . Mar 23, 2026 · It happens in every http framework with a router. Nov 25, 2020 · With that request you are calling this. . If you remove the ParseInt directives, the routes work fine. This ordering is really important, as you'll face same exact issue in all major http framework with a router. z2cy7alhszdl2gsrpkxpywgwt6qouphuzkelhjdsnam6iyk8uczw9sdeoxqjoyabwr418ohplyiskco06shrbgqiefclfwiozaog08c5y7yte