Validate array in Body decorator
See original GitHub issueDescription
Body of type array is not validated.
Minimal code-snippet showcasing the problem
@Post('/save')
save( @Body({ type: Hall, validate: true }) halls: Hall[]) { }
Expected behavior
The body should have been validated
Actual behavior
The body is not validated
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:6 (1 by maintainers)
Top Results From Across the Web
NestJs validate array in request body - Stack Overflow
To validate the array, create a dedicated class which contains a property that wraps the array, or use the ParseArrayPipe .
Read more >NestJS #25 - Decorator Based Validation | Using Class Validator
Decorator -based validation is a technique to validate the incoming request data using the Class- validator package. We can validate data such ...
Read more >Pipes | NestJS - A progressive Node.js framework
A pipe is a class annotated with the @Injectable() decorator, ... context of validating route parameters, query string parameters and request body values....
Read more >Validate array in Body decorator - - Bountysource
Javascript Required. Kindly enable Javascript. · Validate array in Body decorator · Description · Expected behavior · Actual behavior · Updates ...
Read more >Validation - Laravel - The PHP Framework For Web Artisans
Available Validation Rules; Conditionally Adding Rules; Validating Arrays. Validating Nested Array Input ... 'body.required' => 'A message is required',.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Any updates on this?
Running into the same issue as @manofteal mentions. When passing an array (which I don’t want), it gets passed to my controller method, unvalidated. Any update on this?
Edit: @attilaorosz I checked your two potential solutions, but shouldn’t we just disable passing arrays as a body? Nest does it that way, because like you mentioned, it’s a TS issue.