fastify yup schema validator
yarn add fastify-yup-schema
or
npm install fastify-yup-schema
Register Plugin
import { fastifyYupSchema } from "fastify-yup-schema";
fastify.register(fastifyYupSchema);
Yup options are available and you can edit them
fastify.register(fastifyYupSchema,{...});
Create yup schema
import { createYupSchema } from "fastify-yup-schema";
export const testSchema = createYupSchema((yup) => ({
params: yup.object({ id: yup.string().required() }).required(),
}));
Use yup schema
import { testSchema } from "../schemas";
fastify.get(
"/:id",
{ schema: testSchema },
...
);
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.