Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

318
Views
Yup validation for two fields, when one field changes make other field null

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

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!