feat: Remove ZodFilter and ZodPipe classes
The ZodFilter and ZodPipe classes located under src/pipes have been completely removed. This includes deletion of all features, methods, and imports associated with these classes.
This commit is contained in:
parent
6905e8faee
commit
ed19be6369
@ -1,17 +0,0 @@
|
||||
import { ArgumentsHost, Catch, ExceptionFilter, HttpStatus } from "@nestjs/common";
|
||||
import { ZodError } from "zod";
|
||||
|
||||
|
||||
@Catch(ZodError)
|
||||
export class ZodFilter<T extends ZodError> implements ExceptionFilter {
|
||||
catch(exception: T, host: ArgumentsHost) {
|
||||
const ctx = host.switchToHttp();
|
||||
const response = ctx.getResponse();
|
||||
const status = HttpStatus.BAD_REQUEST;
|
||||
response.status(status).json({
|
||||
errors: exception.errors,
|
||||
message: exception.message,
|
||||
statusCode: status,
|
||||
});
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
import { ArgumentMetadata, Injectable, PipeTransform } from "@nestjs/common";
|
||||
import { z } from "zod";
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class ZodPipe implements PipeTransform {
|
||||
constructor(private readonly schema: z.ZodObject<any>) {}
|
||||
|
||||
transform(value: any, metadata: ArgumentMetadata) {
|
||||
this.schema.parse(value);
|
||||
return value;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user