zod-adapter-formik
v2.0.0
Published
An adapter of zod object validation to Formik validation schema
Readme
zod-formik-adapter
This library adapts a zod schema to work as a validationSchema prop or validate prop on Formik
Install
npm install zod-formik-adapter
# or
yarn add zod-formik-adapter
# or
pnpm add zod-formik-adapter
# or
bun add zod-formik-adapterUsage
// use "zod/v3" if you are using zod v3
import * as z from 'zod'
import { Formik } from 'formik';
// use "zod-formik-adapter/v3" if you are using zod v3
import { toFormikValidationSchema } from 'zod-formik-adapter';
const Schema = z.object({
name: z.string(),
age: z.number(),
});
const Component = () => (
<Formik
validationSchema={toFormikValidationSchema(Schema)}
>
{...}
</Formik>
);import * as 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>
);