I want to validate one field on the basis of other using my schema. Like, if carType is "SUV" maximum "noOfPassengers" should be 6 else 4. But, it's not validating this case, neither I can debug this nor getting any error in console.
const validationSchema = yup.object().shape({
location: yup
.string()
.required('location is required'),
destination: yup
.string()
.required('Destination is required'),
carType: yup
.string(),
noOfPassengers: yup
.string()
.when('carType', {
is: value => value && value === "SUV",
then: yup
.string()
.max(6, 'Max 6 passengers are required'),
otherwise: yup
.string()
.max(4, 'Max 4 passengers are required'),
}),
});