Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] schema with transform has type mismatch #20

Open
bastibuck opened this issue Feb 13, 2023 · 0 comments
Open

[BUG] schema with transform has type mismatch #20

bastibuck opened this issue Feb 13, 2023 · 0 comments

Comments

@bastibuck
Copy link

Describe the bug
When describing a schema that has one or more transform()s.
Right now a type error is shown when using validationSchema: toFormikValidationSchema(mySchema),.

To Reproduce
Steps to reproduce the behavior:

  1. Create a schema containing transform e.g. string => number
  2. Use toFormikValidationSchema with that schema
  3. See error
The types of '_input.age' are incompatible between these types.
    Type 'string' is not assignable to type 'number'.

Expected behavior
The TypeError should not be shown as only the fully transformed type should be considered.

Node version: 19.12.0

Zod, Formik and zod-formik-adapter versions:

  • Zod: 3.20.6
  • Formik: 2.2.9
  • zod-formik-adapter: 1.2.0

Additional context
Check this CodeSandbox for example https://codesandbox.io/s/formik-zod-test-forked-eyoy4j?file=/index.tsx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant