Introduce an easy way to create errors from `onSubmit`

Đang mở
#2,188 7 bình luận 54 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@LeCarbonator đang làm issue này rồi.

Từ ngày 19/5/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

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!

Ngôn ngữ chính
TypeScript
Star
6.8k
Fork
717
Merge trung bình
5 ngày 22 giờ
Pull request đã merge (30 ngày)
14

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của TanStack/form

Tất cả issue của TanStack/form

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.