2.0.1 • Published 2 months ago

formik-validator-zod v2.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Formik Validator Zod

Allows you to easily validate Formik forms with the power of Zod schemas.

WARNING: As of v2, this package uses native ESM and no longer provides a CommonJS export. If this is something you need, you should be able to use the dynamic import function or use v1 of this package.

Installation

This package is published both on NPM and JSR.

To install from NPM:

npm install formik-validator-zod

yarn add formik-validator-zod

bun add formik-validator-zod

To install from JSR:

npx jsr add @glazy/formik-validator-zod

yarn dlx jsr add @glazy/formik-validator-zod

bunx jsr add @glazy/formik-validator-zod

Example

import { Formik } from 'formik'
import { z } from 'zod'
import { withZodSchema } from 'formik-validator-zod'

const mySchema = z.object({
  email: z.string().email(),
  name: z.string(),
  age: z.number(),
})

const MyForm = () => {
  return (
    <Formik validate={withZodSchema(mySchema)} {...}>
      {...}
    </Formik>
  )
}
2.0.1

2 months ago

2.0.0

6 months ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago