Replies: 4 comments
-
Try this https://github.com/toonvanstrijp/nestjs-i18n/tree/main/samples/dto-validation. Also show your i18n files. |
Beta Was this translation helpful? Give feedback.
-
Looks like problem is with testing environment. Idk how it can relate, but in fact - I tested this setup with live app, and error messages were translated correctly. Then I've launched exact same code with supertest - and got bugged error messages. Perharps all another error messages with supertest were ok, except these for id check |
Beta Was this translation helpful? Give feedback.
-
In main.ts you should use I18ValidationPipe() instead of ValidationPipe() |
Beta Was this translation helpful? Give feedback.
-
import { ValidationPipe } from '@nestjs/common'; If I remove these lines my application runs successfully. I wasted my time on this. 😡 |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
I've got very strange bug with some of
class-validator
identifiers -i18nValidationMessage
does not translate message for them. All setup except details is same as described in quickstart guide.Here's my setup to reproduce.
DTO with decorators:
validation.id.int
andvalidation.id.min
are simple strings,Id should be integer number
andId should be positive
.Actual result I have with this setup:
I've tried some antoher decorators, such as
IsNotEmpty
,IsEmail
,IsStrongPassword
, and translation for them is working correctly. Also I've done some check for this case withI18nService
- it translatesvalidation.id.int
andvalidation.id.min
correctly.Reproduction
Provided in description
System Info
Used Package Manager
npm
Validations
Beta Was this translation helpful? Give feedback.
All reactions