I wanted to put two conditions that if its isProduct
or isBox
is true, then product_id
should be required. I did this code below and it isnt working
product_id: yup.string().when(['isProduct', 'isBox'], {
is: true,
then: yup.string().required('Select product'),
}),
Currently, you are checking if both fields are true, in order to check either of the fields is true, you need to override is property to function returning boolean value:
Ref: https://github.com/jquense/yup#mixedwhenkeys-string--arraystring-builder-object--value-schema-schema-schema