Closed pejold closed 2 months ago
I am using nestjs-i18n for DTO validation with the global validation method. I attempted to exclude the 'target' property from the detailed error response by configuring the validationError.target option in the ValidationPipe, as shown below:
nestjs-i18n
validationError.target
ValidationPipe
// src/main.ts import { NestFactory } from '@nestjs/core'; import { NestExpressApplication } from '@nestjs/platform-express'; import { I18nValidationExceptionFilter, I18nValidationPipe } from 'nestjs-i18n'; async function bootstrap() { const app = await NestFactory.create<NestExpressApplication>(AppModule); app.useGlobalPipes( new I18nValidationPipe({ validationError: { target: false, }, }), ); app.useGlobalFilters( new I18nValidationExceptionFilter({ detailedErrors: true, }), ); }
However, with this configuration, any request that fails validation results in a server error response like this:
{ "statusCode": 500, "message": "Internal server error" }
The issue is caused by the commit fdd63a4, which includes code that attempts to access the target property from the error object.
target
error
Set 'validationError.target' value in 'ValidationPipe' to 'false'.
System: OS: macOS 14.6.1 CPU: (8) arm64 Apple M2 Memory: 161.83 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 20.17.0 - /opt/homebrew/opt/node@20/bin/node Yarn: 1.22.22 - /opt/homebrew/bin/yarn npm: 10.8.2 - /opt/homebrew/opt/node@20/bin/npm Browsers: Chrome: 128.0.6613.120 Edge: 128.0.2739.67 Safari: 17.6
yarn
Describe the bug
I am using
nestjs-i18n
for DTO validation with the global validation method. I attempted to exclude the 'target' property from the detailed error response by configuring thevalidationError.target
option in theValidationPipe
, as shown below:However, with this configuration, any request that fails validation results in a server error response like this:
The issue is caused by the commit fdd63a4, which includes code that attempts to access the
target
property from theerror
object.Reproduction
Set 'validationError.target' value in 'ValidationPipe' to 'false'.
System Info
Used Package Manager
yarn
Validations