@tanstack/form-core 0.26.4 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/FormApi.ts CHANGED
@@ -37,9 +37,10 @@ export type FormValidateFn<
37
37
  export type FormValidateOrFn<
38
38
  TFormData,
39
39
  TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,
40
- > = TFormValidator extends Validator<TFormData, infer TFN>
41
- ? TFN
42
- : FormValidateFn<TFormData, TFormValidator>
40
+ > =
41
+ TFormValidator extends Validator<TFormData, infer TFN>
42
+ ? TFN
43
+ : FormValidateFn<TFormData, TFormValidator>
43
44
 
44
45
  /**
45
46
  * @private
@@ -59,9 +60,10 @@ export type FormValidateAsyncFn<
59
60
  export type FormAsyncValidateOrFn<
60
61
  TFormData,
61
62
  TFormValidator extends Validator<TFormData, unknown> | undefined = undefined,
62
- > = TFormValidator extends Validator<TFormData, infer FFN>
63
- ? FFN | FormValidateAsyncFn<TFormData, TFormValidator>
64
- : FormValidateAsyncFn<TFormData, TFormValidator>
63
+ > =
64
+ TFormValidator extends Validator<TFormData, infer FFN>
65
+ ? FFN | FormValidateAsyncFn<TFormData, TFormValidator>
66
+ : FormValidateAsyncFn<TFormData, TFormValidator>
65
67
 
66
68
  export interface FormValidators<
67
69
  TFormData,
@@ -587,7 +589,7 @@ export class FormApi<
587
589
  field: TField,
588
590
  cause: ValidationCause,
589
591
  ) => {
590
- // eslint-disable-next-line ts/no-unnecessary-condition
592
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
591
593
  const fieldInstance = this.fieldInfo[field]?.instance
592
594
  if (!fieldInstance) return []
593
595
 
@@ -843,7 +845,7 @@ export class FormApi<
843
845
  getFieldInfo = <TField extends DeepKeys<TFormData>>(
844
846
  field: TField,
845
847
  ): FieldInfo<TFormData, TFormValidator> => {
846
- // eslint-disable-next-line ts/no-unnecessary-condition
848
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
847
849
  return (this.fieldInfo[field] ||= {
848
850
  instance: null,
849
851
  validationMetaMap: {
@@ -1093,6 +1095,18 @@ export class FormApi<
1093
1095
  this.validateField(`${field}[${index1}]` as DeepKeys<TFormData>, 'change')
1094
1096
  this.validateField(`${field}[${index2}]` as DeepKeys<TFormData>, 'change')
1095
1097
  }
1098
+ /**
1099
+ * Updates the form's errorMap
1100
+ */
1101
+ setErrorMap(errorMap: ValidationErrorMap) {
1102
+ this.store.setState((prev) => ({
1103
+ ...prev,
1104
+ errorMap: {
1105
+ ...prev.errorMap,
1106
+ ...errorMap,
1107
+ },
1108
+ }))
1109
+ }
1096
1110
  }
1097
1111
 
1098
1112
  function normalizeError(rawError?: ValidationError) {
package/src/mergeForm.ts CHANGED
@@ -24,7 +24,7 @@ export function mutateMergeDeep(target: object, source: object): object {
24
24
  mutateMergeDeep(target[targetKey] as {}, source[sourceKey] as {})
25
25
  } else {
26
26
  // Prevent assigning undefined to target, only if undefined is not explicitly set on source
27
- // eslint-disable-next-line ts/no-unnecessary-condition
27
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
28
28
  if (!(sourceKey in source) && source[sourceKey] === undefined) {
29
29
  continue
30
30
  }