fix: class-validators and nest.js: Global custom validator with imports from two different modules is only triggered in one of the two modules #2320
Labels
status: needs triage
Issues which needs to be reproduced to be verified report.
type: fix
Issues describing a broken feature.
Description
I am using
Nest.js
andclass-validator
. If the same validator is being used in two different modules, and Dto Objects from both of the modules are being used inside the validator, the validator only triggers in one of the two modules. Main suspect is a circural dependency.Minimal code-snippet showcasing the problem
https://github.com/SakisTsalk/nestjs-custom-validators-issue
Steps to reproduce:
yarn install
yarn start:dev
curl --location 'http://localhost:3000/dogs/create' \ --header 'Content-Type: application/json' \ --data '{ "dog": { "name": "rex" } }'
curl --location 'http://localhost:3000/cats/create' \ --header 'Content-Type: application/json' \ --data '{ "cat": { "name": "kittie" } }'
Expected behavior
I would expect that an error is thrown during build time or at least when the validator is triggered.
Actual behavior
No error is thrown the validator works correctly in one of the modules, but is completely ignored from the other module
Same issue reported in
nest.js
side:nestjs/nest#12847
The text was updated successfully, but these errors were encountered: