import { Injectable, ValidationPipe } from '@nestjs/common'; import { RpcException } from '@nestjs/microservices'; @Injectable() export class RpcValidationPipe extends ValidationPipe { createExceptionFactory() { return (validationErrors = []) => { return new RpcException({ code: 3, message: this.flattenValidationErrors(validationErrors), }); }; } }