TanStack / form

🤖 Powerful and type-safe form state management for the web. TS/JS, React Form, Solid Form, Lit Form and Vue Form.

Home Page:https://tanstack.com/form

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

can't provide validatorAdapter when using createFormFactory

barsikus007 opened this issue · comments

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

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

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!

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>

whoops I duped this :) #669