#Use global ValidationPipe on custom pipeline

17 messages · Page 1 of 1 (latest)

humble flax
#

Show code.

#

What is IdentifyCustomer and Customer is the same as CustomerDto ?

#

I tried to look here in the documentation if I could find something, I can't tell you. But the way you're doing it seems very strange to me, but it has nothing to do with what you asked for.

#

I think it's better to wait for a member of the core team to come and help you.

#

I wonder why you are trying to create a customPipe if you can simply pass the DTO as typing to the body.

#

That's why I didn't question it, maybe you were trying to do something different on your own... Sometimes I do that but I think this solution you created isn't very useful.

#
  @Post('/customerIdentify')
  async login(
    @Body() intendedApp: CustomerDto, {}
  } 
humble flax
#

I see... I don't know a good way to do it

#

You can do this after the validation

#

IntendedApp will be exactly CustomerDto

#

So you pass it to the service and there you turn into Customer

#

Can not be that way ?

#

This way, dto will 100% validate and you will transform it after..

nimble sphinx
#

.

icy glacier
#

try something like this
@UsePipes(new ValidationPipe({ transform: true }))
@UsePipes(SanitizeNamePipe)
@UsePipes(ValidateAgePipe)
async createUser(@Body() createUserDto: CreateUserDto) {