Description
Describe the bug
I'm using react hook form and trying to use the functionality where you can nest objects. The use case is for one field that contains several related checkboxes. When validating a nested object an uncaught error is thrown because entry
is undefined on line 56 of NopeObject.js
.
To Reproduce
Steps to reproduce the behavior:
Include the code and entry
Validation code:
Nope.object().shape({
email: Nope.string().email().required(),
options: Nope.object({
a: Nope.boolean(),
b: Nope.boolean()
})
})
Entry Example 1:
{
email: something@something.com
}
Entry Example 2:
{
email: something@something.com,
options: {
a: true,
b: false
}
}
Expected behavior
The above should skip undefined when validating objects that aren't required. Required functionality would also be nice if possible for NopeObject.js.
Environment (please complete the following information):
- Browser/Node version
Chrome/v14.15.0
Additional context
The optional object in our case is a legal requirement. Based on another field this field will show. That's why it would be nice to have this check if the object is undefined on the line mentioned above.