Describe the bug
Hey 👋,
I was recently working on a project with tanstack/form where I was using it form a multistep form.
In order to validate fields for each steps, I was using form.validate("stepField"). I actually figure that array fields with children validation does not seem to be correctly validated
It wrote a quick unit test in order to make it clearer
it('should correctly validate array items with a schema', async () => {
const form = new FormApi({
defaultValues: {
names: [] as string[],
},
validators: {
onSubmit: z.object({
names: z.array(z.string().max(1)),
})
}
})
form.mount()
const field = new FieldApi({
form,
name: 'names',
})
field.mount()
field.pushValue("that more than 3 characters and should fail")
const issueResult = await field.validate("submit")
expect(issueResult).toBeDefined()
expect(Array.isArray(issueResult)).toBe(true)
expect(issueResult.length).toBeGreaterThan(0)
})
and it output like this

Hope it can be hopeful ! I start to deep dive the codebase, and if end-up being a real issue i would love to contribute 👍
Your minimal, reproducible example
Provided in the description
Steps to reproduce
- Define an field with for example
z.array(z.string().max(1))
- Input a value that does not match the schema
- Call validate on the field
- Error should be reported indicating that the array item is invalid
Expected behavior
Error should be reported indicating that the array item is invalid
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
- Macos
- Reproduced inside tanstack/form repository
TanStack Form adapter
None
TanStack Form version
1.15.1
TypeScript version
NA
Additional context
No response
Describe the bug
Hey 👋,
I was recently working on a project with tanstack/form where I was using it form a multistep form.
In order to validate fields for each steps, I was using form.validate("stepField"). I actually figure that array fields with children validation does not seem to be correctly validated
It wrote a quick unit test in order to make it clearer
and it output like this

Hope it can be hopeful ! I start to deep dive the codebase, and if end-up being a real issue i would love to contribute 👍
Your minimal, reproducible example
Provided in the description
Steps to reproduce
z.array(z.string().max(1))Expected behavior
Error should be reported indicating that the array item is invalid
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
TanStack Form adapter
None
TanStack Form version
1.15.1
TypeScript version
NA
Additional context
No response