File tree 3 files changed +21
-27
lines changed
3 files changed +21
-27
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,12 @@ import {
3
3
isStandardSchemaValidator ,
4
4
standardSchemaValidators ,
5
5
} from './standardSchemaValidator'
6
- import { getAsyncValidatorArray , getBy , getSyncValidatorArray } from './utils'
6
+ import {
7
+ defaultFieldMeta ,
8
+ getAsyncValidatorArray ,
9
+ getBy ,
10
+ getSyncValidatorArray ,
11
+ } from './utils'
7
12
import type { DeepKeys , DeepValue , UnwrapOneLevelOfArray } from './util-types'
8
13
import type {
9
14
StandardSchemaV1 ,
@@ -1007,13 +1012,7 @@ export class FieldApi<
1007
1012
fn : ( ) => {
1008
1013
const value = this . form . getFieldValue ( this . name )
1009
1014
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,
1017
1016
...opts . defaultMeta ,
1018
1017
}
1019
1018
Original file line number Diff line number Diff line change 1
1
import { Derived , Store , batch } from '@tanstack/store'
2
2
import {
3
+ defaultFieldMeta ,
3
4
deleteBy ,
4
5
functionalUpdate ,
5
6
getAsyncValidatorArray ,
@@ -1724,15 +1725,7 @@ export class FormApi<
1724
1725
return Object . keys ( fieldMeta ) . reduce (
1725
1726
( acc : Record < TField , AnyFieldMeta > , key ) => {
1726
1727
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
1736
1729
return acc
1737
1730
} ,
1738
1731
{ } as Record < TField , AnyFieldMeta > ,
@@ -1969,15 +1962,7 @@ export class FormApi<
1969
1962
...prev ,
1970
1963
fieldMetaBase : {
1971
1964
...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 ,
1981
1966
} ,
1982
1967
values : {
1983
1968
...prev . values ,
Original file line number Diff line number Diff line change 1
1
import type { GlobalFormValidationError , ValidationCause } from './types'
2
2
import type { FormValidators } from './FormApi'
3
- import type { FieldValidators } from './FieldApi'
3
+ import type { AnyFieldMeta , FieldValidators } from './FieldApi'
4
4
5
5
export type UpdaterFn < TInput , TOutput = TInput > = ( input : TInput ) => TOutput
6
6
@@ -376,3 +376,13 @@ export function shallow<T>(objA: T, objB: T) {
376
376
}
377
377
return true
378
378
}
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