8000 How to validate EmittedMessage payload with DTO? Validation is not working for me. · Issue #517 · algoan/nestjs-components · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
How to validate EmittedMessage payload with DTO? Validation is not working for me. #517
Open
@gitSambhal

Description

@gitSambhal

Hi I want to validate the EmittedMessage using the DTO but the validation is not working. I am using Google Pubsub microservice.

export class OrderDTO {
  @IsString()
  @IsNotEmpty()
  public id: string;

   ...
}
@EventPattern(PS_SUBSCRIPTION_EVENTS.CREATE_ORDER_SUBSCRIBE)
  public async handleOrderReceivedFromCustomer(
    @Payload(ValidationPipe)
    data: EmittedMessage<OrderDTO>,
  ): Promise<void> {
    const order = <OrderDTO>data.payload;
    // Do something
}

I have added global validation pipe, tried with controller/param level validation pipes using @UsePipes but still it goes inside the consoller function without throwing the error if I send the empty object in Google Pubsub event data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0