Skip to content
Source
Sign inSign up
TanStack/form

Add 'setErrorMap' api to 'formApi' and 'fieldApi' #821

MergedToavina23(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/821/headmerged by Balastrong(GitHub profile, opens in a new tab)

Showing 4 changed files with 84 additions and 0 deletions (loading 1).

x
0 of 4 viewed, 4 left
13 additions and 0 deletionspackages/form-core/src/FieldApi.tsModified
View file
@@ -963,6 +963,19 @@
this.validate('blur')
+​
+ /**
+ * Updates the field's errorMap
+ */
+ setErrorMap(errorMap: ValidationErrorMap) {
+ this.setMeta((prev) => ({
+ ...prev,
+ errorMap: {
+ ...prev.errorMap,
+ ...errorMap,
+ },
+ }))
+ }
​
function normalizeError(rawError?: ValidationError) {
12 additions and 0 deletionspackages/form-core/src/FormApi.tsModified
View file
@@ -1095,6 +1095,18 @@