File tree Expand file tree Collapse file tree 3 files changed +21
-27
lines changed
Expand file tree Collapse file tree 3 files changed +21
-27
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,12 @@ import {
33 isStandardSchemaValidator ,
44 standardSchemaValidators ,
55} from './standardSchemaValidator'
6- import { getAsyncValidatorArray , getBy , getSyncValidatorArray } from './utils'
6+ import {
7+ defaultFieldMeta ,
8+ getAsyncValidatorArray ,
9+ getBy ,
10+ getSyncValidatorArray ,
11+ } from './utils'
712import type { DeepKeys , DeepValue , UnwrapOneLevelOfArray } from './util-types'
813import type {
914 StandardSchemaV1 ,
@@ -1007,13 +1012,7 @@ export class FieldApi<
10071012 fn : ( ) => {
10081013 const value = this . form . getFieldValue ( this . name )
10091014 const meta = this . form . getFieldMeta ( this . name ) ?? {
1010- isValidating : false ,
1011- isTouched : false ,
1012- isBlurred : false ,
1013- isDirty : false ,
1014- isPristine : true ,
1015- errors : [ ] ,
1016- errorMap : { } ,
1015+ defaultFieldMeta,
10171016 ...opts . defaultMeta ,
10181017 }
10191018
Original file line number Diff line number Diff line change 11import { Derived , Store , batch } from '@tanstack/store'
22import {
3+ defaultFieldMeta ,
34 deleteBy ,
45 functionalUpdate ,
56 getAsyncValidatorArray ,
@@ -1724,15 +1725,7 @@ export class FormApi<
17241725 return Object . keys ( fieldMeta ) . reduce (
17251726 ( acc : Record < TField , AnyFieldMeta > , key ) => {
17261727 const fieldKey = key as TField
1727- acc [ fieldKey ] = {
1728- isValidating : false ,
1729- isTouched : false ,
1730- isBlurred : false ,
1731- isDirty : false ,
1732- isPristine : true ,
1733- errors : [ ] ,
1734- errorMap : { } ,
1735- }
1728+ acc [ fieldKey ] = defaultFieldMeta
17361729 return acc
17371730 } ,
17381731 { } as Record < TField , AnyFieldMeta > ,
@@ -1969,15 +1962,7 @@ export class FormApi<
19691962 ...prev ,
19701963 fieldMetaBase : {
19711964 ...prev . fieldMetaBase ,
1972- [ field ] : {
1973- isValidating : false ,
1974- isTouched : false ,
1975- isBlurred : false ,
1976- isDirty : false ,
1977- isPristine : true ,
1978- errors : [ ] ,
1979- errorMap : { } ,
1980- } ,
1965+ [ field ] : defaultFieldMeta ,
19811966 } ,
19821967 values : {
19831968 ...prev . values ,
Original file line number Diff line number Diff line change 11import type { GlobalFormValidationError , ValidationCause } from './types'
22import type { FormValidators } from './FormApi'
3- import type { FieldValidators } from './FieldApi'
3+ import type { AnyFieldMeta , FieldValidators } from './FieldApi'
44
55export type UpdaterFn < TInput , TOutput = TInput > = ( input : TInput ) => TOutput
66
@@ -376,3 +376,13 @@ export function shallow<T>(objA: T, objB: T) {
376376 }
377377 return true
378378}
379+
380+ export const defaultFieldMeta : AnyFieldMeta = {
381+ isValidating : false ,
382+ isTouched : false ,
383+ isBlurred : false ,
384+ isDirty : false ,
385+ isPristine : true ,
386+ errors : [ ] ,
387+ errorMap : { } ,
388+ }
You can’t perform that action at this time.
0 commit comments