vee-validate
vee-validate copied to clipboard
feat: provide form values as context for yup schema extending #4753
🔎 Overview
This PR improves the implementation from #{4753} by passing the context to yup when passing to form the validation schema.
Example:
setup() {
const validationSchema = yup.object({
password: yup.string().required().min(3).label('Password'),
confirmPassword: yup
.string()
.required()
.oneOf([yup.ref('$password')])
.label('Confirm Password'),
});
return {
validationSchema,
};
},
template: `
<VForm v-slot="{ errors }" :validation-schema="validationSchema">
<Field id="password" name="password" type="password" />
<span id="passwordErr">{{ errors.password }}</span>
<Field id="confirmPassword" name="confirmPassword" type="password" />
<span id="confirmPasswordErr">{{ errors.confirmPassword }}</span>
<button>Validate</button>
</VForm>
✔ Issues affected
extends #{4753}