Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/robertLichtnow/zod-formik-adapter
An adapter for zod object validation to Formik validation schema
https://github.com/robertLichtnow/zod-formik-adapter
Last synced: about 2 months ago
JSON representation
An adapter for zod object validation to Formik validation schema
- Host: GitHub
- URL: https://github.com/robertLichtnow/zod-formik-adapter
- Owner: robertLichtnow
- License: mit
- Created: 2021-08-16T21:40:35.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-04-08T11:04:18.000Z (9 months ago)
- Last Synced: 2024-10-29T00:55:36.400Z (3 months ago)
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/zod-formik-adapter
- Size: 123 KB
- Stars: 159
- Watchers: 4
- Forks: 15
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-zod - `zod-formik-adapter` - Formik adapter for Zod. (Other)
README
# zod-formik-adapter
[![codecov](https://codecov.io/gh/robertLichtnow/zod-formik-adapter/branch/master/graph/badge.svg?token=Z5V1VKCGV9)](https://codecov.io/gh/robertLichtnow/zod-formik-adapter)
This library adapts a [zod](https://www.npmjs.com/package/zod) schema to work as a `validationSchema` prop or `validate` prop on [Formik](https://www.npmjs.com/package/formik)
## Install
```sh
# npm
$ npm install zod-formik-adapter# yarn
$ yarn add zod-formik-adapter
```## Usage
```TSX
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 = () => (
{...}
);
``````TSX
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 = () => (
{...}
);
```