Skip to content
Advertisement

Validate array object – Swagger/NestJS

I am wondering if there’s a way to create a dto to validate array of object?

Example array:

JavaScript

At the moment I have this, while it works, it isn’t what I am after.

JavaScript

Advertisement

Answer

Just use ParseArrayPipe:

Update your Controller:

JavaScript

Ensure to have items and whitelist set.

Update your DTO:

JavaScript
User contributions licensed under: CC BY-SA
12 People found this is helpful
Advertisement