there I'm trying to make this kind of a function, Where if the first field changes value the second field should be null
I have this
start: Yup.date()
.max(new Date(), 'startDateCannotBeHigher')
.required('pleaseWriteStartDate'),
end: Yup.date().when(start, {
is: (start) => start,
then: Yup.date()
.when(
'start',
(start, schema) =>
start &&
schema.min(
new Date(new Date(start).setFullYear(new Date(start).getFullYear() + 1)),
'endDateCannotBeSameAsStartDate'
)
)
.required('pleaseWriteEndDate'),
}),
So when the start field is changed, I want the end to be null.
Thanks a lot