formik-effect-schema
v0.1.0
Published
[![NPM version](https://img.shields.io/npm/v/formik-effech-schema?color=a1b858&label=)](https://www.npmjs.com/package/formik-effech-schema)
Downloads
6
Maintainers
Readme
formik-effect-schema
This library adapts a @effect/schema schema to work as a validationSchema
prop or validate
prop on Formik
Install
# npm
$ npm install formik-effect-schema
# yarn
$ yarn add formik-effect-schema
# pnpm
$ pnpm add formik-effect-schema
Usage
import { Schema as S } from '@effect/schema'
import { Formik } from 'formik';
import { toValidationSchema } from 'formik-effect-schema';
const formSchema = S.Struct({
name: S.String,
age: S.Number,
})
type Values = S.Schema.Type<typeof formSchema>
const Component = () => (
<Formik<Values>
validationSchema={toValidationSchema(formSchema)}
>
{/** ... */}
</Formik>
);
import { Schema as S } from '@effect/schema'
import { Formik } from 'formik';
import { toValidate } from 'formik-effect-schema';
const formSchema = S.Struct({
name: S.String,
age: S.Number,
})
type Values = S.Schema.Type<typeof formSchema>
const Component = () => (
<Formik<Values>
validate={toValidate(formSchema)}
>
{/** ... */}
</Formik>
);