An example of a field that requires a numeric value that cannot be higher than the multiplication of two other field’s values
const validationSchema = Yup.object().shape({
num1: Yup.number().positive().required('This field is required.'),
num2: Yup.number().positive().required('This field is required.'),
num3: Yup.number().positive().required('This field is required.')
.when(['num1', 'num2'], (num1, num2, schema) => {
return num1 > 0 && num2 > 0 ? schema.max(num1 / num2) : schema.max(0);
})
});