1
- import { type DeepKeys , type DeepValue , type Updater } from './utils'
2
- import type { FormApi , ValidationErrorMap } from './FormApi'
3
1
import { Store } from '@tanstack/store'
4
- import type { Validator , ValidationError } from './types'
2
+ import type { FormApi , ValidationErrorMap } from './FormApi'
3
+ import type { ValidationError , Validator } from './types'
4
+ import type { DeepKeys , DeepValue , Updater } from './utils'
5
5
6
6
export type ValidationCause = 'change' | 'blur' | 'submit' | 'mount'
7
7
@@ -243,6 +243,7 @@ export class FieldApi<
243
243
unsubscribe ( )
244
244
if ( ! preserveValue ) {
245
245
delete info . instances [ this . uid ]
246
+ this . form . deleteField ( this . name )
246
247
}
247
248
248
249
if ( ! Object . keys ( info . instances ) . length && ! preserveValue ) {
@@ -494,7 +495,7 @@ export class FieldApi<
494
495
}
495
496
496
497
// Always return the latest validation promise to the caller
497
- return this . getInfo ( ) . validationPromise ?? [ ]
498
+ return ( await this . getInfo ( ) . validationPromise ) ?? [ ]
498
499
}
499
500
500
501
validate = (
@@ -504,6 +505,10 @@ export class FieldApi<
504
505
// If the field is pristine and validatePristine is false, do not validate
505
506
if ( ! this . state . meta . isTouched ) return [ ]
506
507
508
+ try {
509
+ this . form . validate ( cause )
510
+ } catch ( _ ) { }
511
+
507
512
// Store the previous error for the errorMapKey (eg. onChange, onBlur, onSubmit)
508
513
const errorMapKey = getErrorMapKey ( cause )
509
514
const prevError = this . getMeta ( ) . errorMap [ errorMapKey ]
0 commit comments