I have a problem in validation. I wanted that if access
value is 1 then you can select the start_date
and end_date
BUT if the value of access
is not 1, then you can only select today.
Codesandbox
export const validationSchema = yup.object().shape({
access: yup.number().nullable(),
start_date: yup.string().required('Select start date'),
end_date: yup.string().required('Select end date'),
});
Instead of string validation you can use date validation, just make sure to set correct messaging!:
Update stackblitz can be found here.