@@ -569,7 +569,11 @@ export function useForm<
569569 /**
570570 * Sets a single field value
571571 */
572- function setFieldValue < T extends Path < TValues > > ( field : T | PathState , value : PathValue < TValues , T > | undefined ) {
572+ function setFieldValue < T extends Path < TValues > > (
573+ field : T | PathState ,
574+ value : PathValue < TValues , T > | undefined ,
575+ shouldValidate = true
576+ ) {
573577 const clonedValue = deepCopy ( value ) ;
574578 const path = typeof field === 'string' ? field : ( field . path as Path < TValues > ) ;
575579 const pathState = findPathState ( path ) ;
@@ -578,6 +582,9 @@ export function useForm<
578582 }
579583
580584 setInPath ( formValues , path , clonedValue ) ;
585+ if ( shouldValidate ) {
586+ validateField ( path ) ;
587+ }
581588 }
582589
583590 /**
@@ -599,7 +606,7 @@ export function useForm<
599606 } ,
600607 set ( value ) {
601608 const pathValue = unref ( path ) ;
602- setFieldValue ( pathValue , value ) ;
609+ setFieldValue ( pathValue , value , false ) ;
603610 pathState . validated = true ;
604611 pathState . pending = true ;
605612 validateField ( pathValue ) . then ( ( ) => {
@@ -644,7 +651,7 @@ export function useForm<
644651 const newValue = state && 'value' in state ? state . value : getFromPath ( initialValues . value , field ) ;
645652
646653 setFieldInitialValue ( field , deepCopy ( newValue ) ) ;
647- setFieldValue ( field , newValue as PathValue < TValues , typeof field > ) ;
654+ setFieldValue ( field , newValue as PathValue < TValues , typeof field > , false ) ;
648655 setFieldTouched ( field , state ?. touched ?? false ) ;
649656 setFieldError ( field , state ?. errors || [ ] ) ;
650657 }
@@ -660,7 +667,7 @@ export function useForm<
660667 state . validated = false ;
661668 state . touched = resetState ?. touched ?. [ state . path as Path < TValues > ] || false ;
662669
663- setFieldValue ( state . path as Path < TValues > , getFromPath ( newValues , state . path ) ) ;
670+ setFieldValue ( state . path as Path < TValues > , getFromPath ( newValues , state . path ) , false ) ;
664671 setFieldError ( state . path as Path < TValues > , undefined ) ;
665672 } ) ;
666673
0 commit comments