-
Notifications
You must be signed in to change notification settings - Fork 933
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
when
and test
stopped working together
#2205
Comments
This is happening because your .when('$model.isStringValueType', {
is: true,
- then: () => string().required(),
+ then: schema => schema.required(),
}) |
@jquense thanks for reply, but what should I do if I need to return different schemas? e.g. string or number depending on condition? It worked fine before, it is not very clear what to do now. |
Switching types isn't really supported, it didn't work fine before, it was very inconsistent and often produced broken schema which is why it was removed. You are welcome to return a brand new schema still, but it won't be automatically |
Describe the bug
After migrating to yup v1.4
when
andtest
stopped working together, worked fine in 0.32.11.To Reproduce
Codesanbox removed ability to run tests, https://codesandbox.io/docs/learn/sandboxes/faq#where-can-i-find-the-tests-tab, so I am not sure where to add runnable test
But here simplified code and test example that worked in previous versions of yup:
Code here
At the moment, 2nd and 3rd test fails.
Expected behavior
tests should pass, both
.when
and.test
branches should be checkedPlatform (please complete the following information):
Additional context
This is recreation of #2179
The text was updated successfully, but these errors were encountered: