You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lets imagine we have an object with two child objects, but both of them optional.
{
one: { ... },
two: { ... }
}
My problem is I have to check for required fields inside of these objects, but only if these objects themselves exist. So I naively tried the following:
two: object()
.when('two', {
is: (two) => typeof two !== 'undefined',
then: TwoSchema
})
...and of course got cyclic dependency error.
What I ended up doing was passing 2 additional variables to context: $isOneDefined/$isTwoDefined.
Is there a better approach?
The text was updated successfully, but these errors were encountered:
Lets imagine we have an object with two child objects, but both of them optional.
My problem is I have to check for required fields inside of these objects, but only if these objects themselves exist. So I naively tried the following:
...and of course got cyclic dependency error.
What I ended up doing was passing 2 additional variables to context: $isOneDefined/$isTwoDefined.
Is there a better approach?
The text was updated successfully, but these errors were encountered: