Introduce an easy way to create errors from `onSubmit`

オープン
#2,188 コメント 7 件 リアクション 54 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@LeCarbonator がすでに取り組んでいます。

2026年5月19日 から。

評価

この issue はまだ評価されていません。

説明

type: enhancement v1

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!

主要言語
TypeScript
スター
6.8k
フォーク
717
平均マージ
5日 22時間
マージ済み PR(30日)
14

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

TanStack/form のほかの issue

TanStack/form の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。