feat: move to V2
CI / build-and-test (push) Canceled after 0s

This commit is contained in:
2026-10-29 11:21:52 +01:00
parent 6342b8451e
commit 314717ba3a
244 changed files with 11615 additions and 15292 deletions
+17
View File
@@ -0,0 +1,17 @@
import { BadRequestException, PipeTransform } from '@nestjs/common';
import { z } from 'zod';
/** Validates and converts a body or query with a schema from @kooltap/shared: `@Body(zod(schema))`. */
export class ZodPipe<S extends z.ZodType> implements PipeTransform<unknown, z.output<S>> {
constructor(private readonly schema: S) {}
transform(value: unknown): z.output<S> {
const result = this.schema.safeParse(value);
if (!result.success) {
throw new BadRequestException({ code: 'validation_error', message: z.prettifyError(result.error) });
}
return result.data;
}
}
export const zod = <S extends z.ZodType>(schema: S) => new ZodPipe(schema);