DEV Community

Discussion on: Validating nested objects with class-validator in NestJS

Collapse
 
avantar profile image
Krzysztof Szala

Are you sure that items property is not null / undefined? Maybe it didn't come in the request?

Collapse
 
olustrrax profile image
dan's cat

Finally I knew why it wasn't work for me. Because I wrote nested object in array more than couple layers. By the way I have fixed it by customized validate pipe when it received bad request exception. Now it works for me!

Thread Thread
 
oliverqueen2003 profile image
oliverqueen2003

Can you share your code?

Thread Thread
 
navinmishra1717 profile image
Navin Mishra • Edited

i was able to solve this problem with the help of custom recursive function in global validation pipe like this:

helper.js
Image description

and in main.ts

Image description