1.0.0 • Published 3 years ago
@artizon/zod-formik-adapter v1.0.0
FORK zod-formik-adapter
A fork of @robertLichtnow's zod-formik-adapter. Compatible with React v18 and zod v3
This library adapts a zod schema to work as a validationSchema prop on Formik
IMPORTANT: Currently, this library does not work with zod union. See more here.
Install
# npm
$ npm install zod-formik-adapter
# yarn
$ yarn add zod-formik-adapterUsage
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>
);1.0.0
3 years ago