TanStack / TanStack/form

Introduce an easy way to create errors from `onSubmit`

Open
#2,188 7 comments 54 reactions 1 assignee View on GitHub

@LeCarbonator is already working on this.

Since May 19, 2026.

type: enhancement v1
Dominant language
TypeScript
Stars
6.7k
Forks
682
Avg merge
5d 18h
Merged PRs (30d)
7

Description

While discussing items we want to improve for a future v2, validation around onSubmit has come up a number of times.

As such, we're going to be backporting an API coming in v2 to the current version of Form (v1):

useForm({
   // ...
   onSubmit: async ({ value, createValidationError }) => {
     try {
        await callEndpoint(value)
        navigateToOverview()
     } catch (error) {
        if (error.code === 400) {
           return createValidationError({ form: `The endpoint had an issue: ${error.message}` }) 
        }
     }
   }
})

This work needs https://github.com/TanStack/form/pull/2128 to be merged first to avoid headaches with generics, but that should come shortly.

We want to hear from you if this API works/doesn't work for your needs and, if not, why not.

Thanks all!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.