Skip to content

Latest commit

 

History

History
55 lines (43 loc) · 1.08 KB

README.md

File metadata and controls

55 lines (43 loc) · 1.08 KB

zod-formik-adapter

codecov

This library adapts a zod schema to work as a validationSchema prop or validate prop on Formik

Install

# npm
$ npm install zod-formik-adapter

# yarn
$ yarn add zod-formik-adapter

Usage

import { z } from 'zod';
import { Formik } from 'formik';
import { toFormikValidationSchema } from 'zod-formik-adapter';

const Schema = z.object({
  name: z.string(),
  age: z.number(),
});

const Component = () => (
  <Formik
    validationSchema={toFormikValidationSchema(Schema)}
  >
    {...}
  </Formik>
);
import { z } from 'zod';
import { Formik } from 'formik';
import { toFormikValidate } from 'zod-formik-adapter';

const Schema = z.object({
  name: z.string(),
  age: z.number(),
});

const Component = () => (
  <Formik
    validate={toFormikValidate(Schema)}
  >
    {...}
  </Formik>
);