add custom validation pipe

This commit is contained in:
Gsk54
2022-12-23 11:00:34 +01:00
parent 4667e57f0c
commit 4e2ee28219
4 changed files with 47 additions and 5 deletions

View File

@@ -0,0 +1,14 @@
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),
});
};
}
}