jquense / yup

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

Outer scope test conflicts with inner scope #2144

Closed runningdavid closed 11 months ago

runningdavid commented 11 months ago

Describe the bug I use array().of(object({value: string})) and I use "matches" for string formatting but also applies a .test on the array to make sure string don't contain duplicates. However, sometimes, depending on the implementation of the .test on the array, the error messages from string validation will have the wrong index.

To Reproduce

I'm using yup 1.3.2 with react-hook-form 7.48.2

Create a schema with array().of(object{value: string()})

put validation on string() as well as a custom .test() on array

Expected behavior There seems to be a bug in my .test code. Fixing the bug also fixed the issue. But I think .test is not expected to affect an inner scope validation.

Platform (please complete the following information):

Additional context Add any other context about the problem here.

jquense commented 11 months ago

If you want help you need to follow the issue template, i don't have time to guess at how to reproduce your issue