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

can't provide validatorAdapter when using createFormFactory #610

Open
barsikus007 opened this issue Feb 29, 2024 · 4 comments
Open

can't provide validatorAdapter when using createFormFactory #610

barsikus007 opened this issue Feb 29, 2024 · 4 comments
Labels
bug good first issue Good for newcomers

Comments

@barsikus007
Copy link

barsikus007 commented Feb 29, 2024

Describe the bug

When I try to specify validatorAdapter in createFormFactory props or formFactory.useForm props, I get these errors:

// createFormFactory
Type '() => { validate({ value }: { value: unknown; }, fn: ZodType<any, ZodTypeDef, any>): ValidationError; validateAsync({ value }: { value: unknown; }, fn: ZodType<any, ZodTypeDef, any>): Promise<...>; }' is not assignable to type 'undefined'.ts(2322)

// formFactory.useForm
Type '() => { validate({ value }: { value: unknown; }, fn: ZodType<any, ZodTypeDef, any>): ValidationError; validateAsync({ value }: { value: unknown; }, fn: ZodType<any, ZodTypeDef, any>): Promise<...>; }' is not assignable to type 'undefined'.ts(2322)

Your minimal, reproducible example

https://stackblitz.com/edit/tanstack-form-vycsno

Steps to reproduce

  1. use createFormFactory with zodValidator adapter
  2. you need to specify validatorAdapter in every field now

Expected behavior

no type error

How often does this bug happen?

None

Screenshots or Videos

No response

Platform

WSL 2

Tanstack Form adapter

react-form

TanStack Form version

0.13.6

TypeScript version

5.3.3

Additional context

No response

@barsikus007
Copy link
Author

I created reproducable example, just use createFormFactory instead of usual form creation:
https://stackblitz.com/edit/tanstack-form-vycsno

@crutchcorn crutchcorn added bug good first issue Good for newcomers labels Mar 4, 2024
@crutchcorn
Copy link
Member

Good catch! For now, you can as never to ignore the problem (or something akin) as it should function, but we'll investigate and fix.

Thanks for the detailed report!

@barsikus007
Copy link
Author

Good catch! For now, you can as never to ignore the problem (or something akin) as it should function, but we'll investigate and fix.

Thanks for the detailed report!

I dig a bit and find another way to solve this issue:

createFormFactory<Model, typeof zodValidator>

@timfee
Copy link

timfee commented Apr 8, 2024

whoops I duped this :) #669

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants