1.0.4 • Published 3 years ago

fastify-yup-schema v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

fastify-yup-schema

Version

fastify yup schema validator

Installation

yarn add fastify-yup-schema
or
npm install fastify-yup-schema

Usage

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 },
  ...
);

Contributing

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.

License

MIT