Skip to content

Yup Validation Context is undefined when using toTypedSchema #5017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
5 tasks done
robinpilz opened this issue Apr 2, 2025 · 0 comments
Open
5 tasks done

Yup Validation Context is undefined when using toTypedSchema #5017

robinpilz opened this issue Apr 2, 2025 · 0 comments

Comments

@robinpilz
Copy link

What happened?

I have a multi step form where I need to make a property required based on a selection in a previous step.

Thankfully the yup context got filled with the form values recently, but when using toTypedSchema the context does not seem to get provided anymore.

Here is the schema with when condition, in my code its placed inside an object():

id: number().when('$prevStep.isUpdate', ([isUpdate], schema) => {
    console.log({ isUpdate });
    return isUpdate ? schema.required() : schema;
});

Without toTypedSchema isUpdate is true/false depending on what the value is
With toTypedSchema isUpdate is undefined

Reproduction steps

Version

Vue.js 3.x and vee-validate 4.x

What browsers are you seeing the problem on?

  • Firefox
  • Chrome
  • Safari
  • Microsoft Edge

Relevant log output

Demo link

No demo

Code of Conduct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant