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.

how to use skipMissingProperties in pipe

See original GitHub issue

I’m submitting a…


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

I hava an entity with class-validator and pipe, and it works well. But the validator will check the params always , it is unexpected. It may be like this: ‘insert’ will check all the params , and ‘update’ will check params which was post, and ‘delete’ will not check;

l have found something about this: skipMissingProperties: true ,and beforeInsert from typeorm, but i dont know when and where to use it ,could u please give me some help?

Environment


Nest version:4.6.6

 
For Tooling issues:
- Node version: 8.9.4  
- Platform: Windows 10 

Others:

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
carmonaccommented, Nov 12, 2018
@Post(':id')
@ApiOperation({
    title: 'Update data of an admin',
    description: 'Post method to edit details about a specific admin',
})
@Authorize(Roles.Admin)
@UsePipes(new ValidationPipe({ skipMissingProperties: true }))
async updateOne(@Param('id') id: string, @Body() admin: UpdateAdminDto) {
    const adminUpdated: IAdmin = await this.adminService.update(id, admin);
    return GenericResponse.Result(null, { adminUpdated });
}

@kamilmysliwiec doing what you propose, it continues validating all properties and I get Bad Request error.

0reactions
lock[bot]commented, Sep 23, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use of Validation Pipe with class-validator - Stack Overflow
In your main.ts , you can add skipMissingProperties: true right into the ValidationPipe. app.useGlobalPipes( new ValidationPipe({ ...
Read more >
Validation | NestJS - A progressive Node.js framework
The ValidationPipe makes use of the powerful class-validator package and its ... skipMissingProperties, boolean, If set to true then validator will skip ...
Read more >
ValidatorOptions - @nestjs/common
Optional skipMissingProperties​​ If set to true than validator will skip validation of all properties that are missing in the validating object.
Read more >
Documentation | NestJS - A progressive Node.js framework
Pipes. A pipe is a class annotated with the @Injectable() decorator. Pipes should implement the PipeTransform interface. Pipes have two typical use cases:....
Read more >
typeorm/typeorm - Gitter
It does, but you have to create a validation pipe (from the examples) and add a ... @mhombach and you are using skipMissingProperties...
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