[ ] Regression
[ ] Bug report
[ ] Feature request
[x] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.
The validationPipe example doesnt works correctly due to an issue with class-transform.
The return of plainToClass should be an instance of class.
const { metatype } = metadata;
const object = plainToClass(metatype, Object.assign({}, value));
const object2 = plainToClass(metatype, value);
console.log(`object: ${object instanceof CreateContactDto}`);
object: true
console.log(`object2: ${object2 instanceof CreateContactDto}`);
object2: false
const object = plainToClass(metatype, Object.assign({}, value));
The example code may change to the code above, to make the validationPipe works correctly.
Nest version: 4.59
For Tooling issues:
- Node version: 8.9.4
- Platform: Windows
Others:
More info about the issue: https://github.com/typestack/class-transformer/issues/112
Hi @silvelo,
Interesting. Thanks for letting me know, will take a look
There's some more info in this issue: https://github.com/typestack/class-transformer/issues/120
I'm currently using this as a temporary fix in my own codebase, in case the issue is not fixed in class-transformer: https://gist.github.com/bjyoungblood/dffe8478696eb10ffd0e477693a023f5#file-validationpipe-ts-L16-L19
It seems that class-transformer team fixed their issue. Also, this PR will be merged soon - https://github.com/nestjs/nest/pull/383 (the latest version will be used here)
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.