How to use Yup validation to make the field mandatory if 1 of the other 3 fields are not empty? I tried the following schema but got cyclic dependency issue. Thank you!
const schema = yup.object().shape({
a: yup.string().when(['b', 'c', 'd'], {
is: (b, c, d) => !b && !c && !d,
then: yup.string().required()
}),
b: yup.string().when(['a', 'c', 'd'], {
is: (a, c, d) => !a && !c && !d,
then: yup.string().required()
}),
c: yup.string().when(['a', 'b', 'd'], {
is: (a, b, d) => !a && !b && !d,
then: yup.string().required()
}),
d: yup.string().when(['a', 'b', 'c'], {
is: (a, b, c) => !a && !b && !c,
then: yup.string().required()
})
}, [['a', 'b', 'c'], ['b', 'c', 'd'], ['a','c', 'd'], ['a','b','d']])