@@ -3222,3 +3222,48 @@ test('provides form values as yup context refs', async () => {
32223222 expect ( pwError ?. textContent ) . toBeFalsy ( ) ;
32233223 expect ( cpwError ?. textContent ) . toBeFalsy ( ) ;
32243224} ) ;
3225+
3226+ test ( 'provides form values as yup context refs for schema validation' , async ( ) => {
3227+ mountWithHoc ( {
3228+ setup ( ) {
3229+ const validationSchema = yup . object ( {
3230+ password : yup . string ( ) . required ( ) . min ( 3 ) . label ( 'Password' ) ,
3231+ confirmPassword : yup
3232+ . string ( )
3233+ . required ( )
3234+ . oneOf ( [ yup . ref ( '$password' ) ] )
3235+ . label ( 'Confirm Password' ) ,
3236+ } ) ;
3237+
3238+ return {
3239+ validationSchema,
3240+ } ;
3241+ } ,
3242+ template : `
3243+ <VForm v-slot="{ errors }" :validation-schema="validationSchema">
3244+ <Field id="password" name="password" type="password" />
3245+ <span id="passwordErr">{{ errors.password }}</span>
3246+
3247+ <Field id="confirmPassword" name="confirmPassword" type="password" />
3248+ <span id="confirmPasswordErr">{{ errors.confirmPassword }}</span>
3249+
3250+ <button>Validate</button>
3251+ </VForm>
3252+ ` ,
3253+ } ) ;
3254+
3255+ const pwError = document . querySelector ( '#passwordErr' ) ;
3256+ const cpwError = document . querySelector ( '#confirmPasswordErr' ) ;
3257+
3258+ await flushPromises ( ) ;
3259+ setValue ( document . querySelector ( '#password' ) as HTMLInputElement , '123' ) ;
3260+ setValue ( document . querySelector ( '#confirmPassword' ) as HTMLInputElement , '12' ) ;
3261+ await flushPromises ( ) ;
3262+
3263+ expect ( pwError ?. textContent ) . toBeFalsy ( ) ;
3264+ expect ( cpwError ?. textContent ) . toBeTruthy ( ) ;
3265+ setValue ( document . querySelector ( '#confirmPassword' ) as HTMLInputElement , '123' ) ;
3266+ await flushPromises ( ) ;
3267+ expect ( pwError ?. textContent ) . toBeFalsy ( ) ;
3268+ expect ( cpwError ?. textContent ) . toBeFalsy ( ) ;
3269+ } ) ;
0 commit comments