15 lines
392 B
TypeScript
15 lines
392 B
TypeScript
|
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),
|
||
|
});
|
||
|
};
|
||
|
}
|
||
|
}
|