Skip to content

Instantly share code, notes, and snippets.

View BenjaminLindberg's full-sized avatar
😃

Benjamin Lindberg BenjaminLindberg

😃
  • Sweden
  • 21:20 (UTC +01:00)
View GitHub Profile
@BenjaminLindberg
BenjaminLindberg / zod-with-fastify.ts
Last active July 26, 2024 17:54
How to use zod with fastify
// Firstly you need to set the validator and serializer compiler to the one included in the fastify-type-provider-zod module. (https://fastify.dev/docs/latest/Reference/Validation-and-Serialization/#validation-and-serialization)
// This can be done like:
import {
serializerCompiler,
validatorCompiler
} from 'fastify-type-provider-zod';
fastify
.setValidatorCompiler(validatorCompiler)
.setSerializerCompiler(serializerCompiler);