@@ -431,7 +431,10 @@ export class FormStore {
431
431
nameList ?: NamePath [ ] ,
432
432
options ?: ValidateOptions ,
433
433
) => {
434
- const namePathList : InternalNamePath [ ] | undefined = nameList && nameList . map ( getNamePath ) ;
434
+ const provideNameList = ! ! nameList ;
435
+ const namePathList : InternalNamePath [ ] | undefined = provideNameList
436
+ ? nameList . map ( getNamePath )
437
+ : [ ] ;
435
438
436
439
// Collect result in promise list
437
440
const promiseList : Promise < {
@@ -440,13 +443,20 @@ export class FormStore {
440
443
} > [ ] = [ ] ;
441
444
442
445
this . getFieldEntities ( ) . forEach ( ( field : FieldEntity ) => {
446
+ // Add field if not provide `nameList`
447
+ if ( ! provideNameList ) {
448
+ namePathList . push ( field . getNamePath ( ) ) ;
449
+ }
450
+
451
+ // Skip if without rule
443
452
if ( ! field . props . rules || ! field . props . rules . length ) {
444
453
return ;
445
454
}
446
455
447
456
const fieldNamePath = field . getNamePath ( ) ;
448
457
449
- if ( ! namePathList || containsNamePath ( namePathList , fieldNamePath ) ) {
458
+ // Add field validate rule in to promise list
459
+ if ( ! provideNameList || containsNamePath ( namePathList , fieldNamePath ) ) {
450
460
const promise = field . validateRules ( {
451
461
validateMessages : {
452
462
...defaultValidateMessages ,
@@ -485,15 +495,15 @@ export class FormStore {
485
495
. then (
486
496
( ) : Promise < Store | string [ ] > => {
487
497
if ( this . lastValidatePromise === summaryPromise ) {
488
- return Promise . resolve ( this . store ) ;
498
+ return Promise . resolve ( this . getFieldsValue ( namePathList ) ) ;
489
499
}
490
500
return Promise . reject < string [ ] > ( [ ] ) ;
491
501
} ,
492
502
)
493
503
. catch ( ( results : { name : InternalNamePath ; errors : string [ ] } [ ] ) => {
494
504
const errorList = results . filter ( result => result && result . errors . length ) ;
495
505
return Promise . reject ( {
496
- values : this . store ,
506
+ values : this . getFieldsValue ( namePathList ) ,
497
507
errorFields : errorList ,
498
508
outOfDate : this . lastValidatePromise !== summaryPromise ,
499
509
} ) ;
0 commit comments