question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValidateNested does not work

See original GitHub issue

I’m submitting a…


[ ] Regression 
[X] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

When using ValidateNested from class-validator to validate a nested object on a dto, the validation passes successfully with invalid nested objects.

Expected behavior

When using ValidateNested to validate a nested object on a dto, the validation should fail with validation rules.

Minimal reproduction of the problem with instructions

https://gist.github.com/chimon2000/d2203b281bbaea570eeccb36ebd6de9b

What is the motivation / use case for changing the behavior?

N/A

Environment


Nest version: 4.6.4

 
For Tooling issues:
- Node version: v8.9.4
- Platform:  Windows

Others:
N/A

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

8reactions
chanlitocommented, Feb 19, 2018
@ValidateNested()
@Type(() => AddressDto) // add this from class-transformer
readonly address: AddressDto
1reaction
ghostcommented, Apr 12, 2019

Is it possible to reopen this issue? I’m currently experiencing this, and unfortunately @chanlito’s solution doesn’t do the trick.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ValidateNested not working · Issue #83 - GitHub
We are using NestJS and are implementing a validation pipe (combination of class-transformer and class-validator). Unfortunately @ ...
Read more >
Validate nested objects using class validator and nestjs
I've just put your code in an empty sample project and it seems to work for me. What specific value is "not working"?...
Read more >
Validating nested objects with class-validator in NestJS
import { ValidateNested } from 'class-validator'; export class Post { @ValidateNested() user: User; }. But for some reason It doesn't work ...
Read more >
API payloads validation and transformation in NestJS - Medium
@ValidateNested() post: Post; }. The above code won't work because when we are trying to transform objects that have nested objects, it's required...
Read more >
Validating Complex Requests With NestJS - Better Programming
If you don't transform — validation will not run. ... @ValidateNested({ each: true }) — triggers an array nested validation, so we can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found