Skip to content

balcieren/fastify-yup-schema

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Fastify Yup Schema Validator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published