I have the following schema:
const baseSchema = {
name: Yup.array().of(
Yup.object().shape({
lang: Yup.string().required(),
value: Yup.string()
.min(2)
.max(20)
.required()
})
)
};
Is there a way to consider the schema valid if at least one of the objects in name
is valid?
Edit: essentially it has to use when()
, but what I'm struggling with is to find out how to check the other elements in the array.
You can use
xor
if you want one of them to be required: