Skip to content
Source
Sign inSign up
TanStack/form

Option for automatically resetting validators #907

Closedoscartbeaumont(GitHub profile, opens in a new tab)wants to merge 8 commits intomain fromrefs/pull/907/headopened

Showing 2 changed files with 21 additions and 0 deletions.

x
0 of 2 viewed, 2 left
7 additions and 0 deletionspackages/form-core/src/FieldApi.tsModified
View file
@@ -932,6 +932,13 @@
this.form.validate(cause)
} catch (_) {}
​
+ // Clear previous validation errors
+ if (this.form.options.automaticallyResetValidators === true)
+ this.setMeta((prev) => ({
+ ...prev,
+ errorMap: {},
+ }))
+​
// Attempt to sync validate first
const { hasErrored } = this.validateSync(cause)
​
14 additions and 0 deletionspackages/form-core/src/FormApi.tsModified
View file
@@ -160,6 +160,20 @@
formApi: FormApi<TFormData, TFormValidator>
}) => void
transform?: FormTransform<TFormData, TFormValidator>
+ /**
+ * When true, all previous validation errors will be cleared when running validation.