jquense / yup

Dead simple Object schema validation
MIT License
22.93k stars 934 forks source link

.when() context is inconsistent #2198

Open DaddyWarbucks opened 7 months ago

DaddyWarbucks commented 7 months ago

Describe the bug When using the third argument of .when() (aka testContext), the transform does not run as expected. Specifically I am trying to use the testContext.index of an array schema to access items retrieved from the when.

To Reproduce I cannot, to save my life, figure out how to open the test panel on Codesandbox. I also was pulling my hair out because Codesandbox was running the code twice and this error is so weird in general. Instead I used StackBlitz. To access the console, inspect the page and it will bring up a separate Chrome DevTools (not embedded like Codesandbox).

https://stackblitz.com/edit/vitejs-vite-r7lfvf?file=main.js

Switch between commenting lines 11 and 14. Although both of these lines of code should do the exact same thing, line 11 does not work.

Expected behavior I can use the testContext.index to retrieve things from context.

Platform (please complete the following information):

Additional context I am happy to work on this and can open a PR. But I am unclear on where to even start.