@@ -119,6 +119,9 @@ export function useForm<
119
119
// If the form is currently submitting
120
120
const isSubmitting = ref ( false ) ;
121
121
122
+ // If the form is currently validating
123
+ const isValidating = ref ( false ) ;
124
+
122
125
// The number of times the user tried to submit the form
123
126
const submitCount = ref ( 0 ) ;
124
127
@@ -517,6 +520,7 @@ export function useForm<
517
520
submitCount,
518
521
meta,
519
522
isSubmitting,
523
+ isValidating,
520
524
fieldArrays,
521
525
keepValuesOnUnmount,
522
526
validateSchema : unref ( schema ) ? validateSchema : undefined ,
@@ -659,6 +663,8 @@ export function useForm<
659
663
return formCtx . validateSchema ( mode ) ;
660
664
}
661
665
666
+ isValidating . value = true ;
667
+
662
668
// No schema, each field is responsible to validate itself
663
669
const validations = await Promise . all (
664
670
pathStates . value . map ( state => {
@@ -680,6 +686,8 @@ export function useForm<
680
686
} )
681
687
) ;
682
688
689
+ isValidating . value = false ;
690
+
683
691
const results : Partial < FlattenAndSetPathsType < TValues , ValidationResult > > = { } ;
684
692
const errors : Partial < FlattenAndSetPathsType < TValues , string > > = { } ;
685
693
for ( const validation of validations ) {
@@ -748,6 +756,8 @@ export function useForm<
748
756
return { valid : true , results : { } , errors : { } } ;
749
757
}
750
758
759
+ isValidating . value = true ;
760
+
751
761
const formResult =
752
762
isYupValidator ( schemaValue ) || isTypedSchema ( schemaValue )
753
763
? await validateTypedSchema < TValues , TOutput > ( schemaValue , formValues )
@@ -756,6 +766,8 @@ export function useForm<
756
766
bailsMap : fieldBailsMap . value ,
757
767
} ) ;
758
768
769
+ isValidating . value = false ;
770
+
759
771
return formResult ;
760
772
}
761
773
@@ -805,6 +817,7 @@ export function useForm<
805
817
...meta . value ,
806
818
values : formValues ,
807
819
isSubmitting : isSubmitting . value ,
820
+ isValidating : isValidating . value ,
808
821
submitCount : submitCount . value ,
809
822
} ) ,
810
823
refreshInspector ,
0 commit comments