Since 2.8.6: Uncaught (in promise) TypeError: Cannot use 'in' operator to search for 'default' in undefined
See original GitHub issueDuring validation, the error below is shown.

This is only in 2.8.6+
I’ve narrowed it down to a piece of my Yup schema, where it’s using ‘.when’ against an element in the parent.
Example:
export const AbcSchema = yup.object().shape({
field1: yup.string().required(),
obj2: yup.object({
obj2Field: yup.string().max(255).when('field1', (field1) => {
if (field1 === 'value') return yup.string().required()
}),
}).nullable()
}
yup: 0.32.11 hookform/resolvers: 2.8.6
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
TypeError: cannot use 'in' operator to search for 'x' in 'y'
The in operator can only be used to check if a property is in an object. You can't search in strings, or in...
Read more >Uncaught TypeError: Cannot use 'in' operator to search for ...
The in operator only works on objects. You are using it on a string. Make sure your value is an object before you...
Read more >Cannot use 'in' operator to search for 'default' in undefined ...
TypeError : Cannot use 'in' operator to search for 'default' in undefined when using getDefault with when on nested object #1503.
Read more >JavaScript TypeError - Cannot use 'in' operator to search for 'X ...
This JavaScript exception Cannot use 'in' operator to search for 'X' in 'Y' occurs if in operator is used to search in strings,...
Read more >TypeError: cannot use 'in' operator to search for 'x' in 'y'
The in operator can only be used to check if a property is in an object. You can't search in strings, or in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thank you for reporting the issue, I’ll fix it tonight
we no longer swallow
errors
from schema, which users should fix their schema error.