fastify-yup-schema
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

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

Package Sidebar

Install

npm i fastify-yup-schema

Weekly Downloads

68

Version

1.0.4

License

MIT

Unpacked Size

13.6 kB

Total Files

8

Last publish

Collaborators

  • urdux