This library adapts a @effect/schema schema to work as a validationSchema
prop or validate
prop on Formik
# npm
$ npm install formik-effect-schema
# yarn
$ yarn add formik-effect-schema
# pnpm
$ pnpm add formik-effect-schema
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>
);