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

241
Views
Yup Validation, Validate at least one field

I have been given a task to change the validation of the form. Requirement is to validate the form when one of the N questions have been answered. I'm sharing the code of how validation is working currently, i.e. it validates form when all of the questions are answered. You can see the questionValidation key here that has the yup validation inside.

 {
companyName: 'ABC',
policyName: 'ABCDEFG',
questionValidation: {
  'Question 1?': Yup.string()
    .matches('No', 'Plan ineligible')
    .required('Required'),
  'Question 2?': Yup.string()
    .matches('No', 'Plan ineligible')
    .required('Required'),
  'Question 3?': Yup.string()
    .matches('Yes', 'Plan ineligible')
    .required('Required'),
},
questionInitialValues: {
  'Question 1?':
    '',
  'Question 2?':
    '',
  'Question 3?':
    '',
},
questionGroups: [
  {
    validationType: 'every',
    questions: [
      {
        label: 'Yes/No',
        question:
          'Question 1?',
        questionType: 'select',
        answers: ['Yes', 'No'],
        knockoutAnswers: ['Yes'],
        questionID: 66,
      },
      {
        label: 'Yes/No',
        question:
          'Question 2?',
        questionType: 'select',
        answers: ['Yes', 'No'],
        knockoutAnswers: ['Yes'],
        questionID: 69,
      },
      {
        label: 'Yes/No',
        question:
          'Question 3?',
        questionType: 'select',
        answers: ['Yes', 'No'],
        knockoutAnswers: ['No'],
        questionID: 72,
      },
    ],
  },
],

}

Need to change code in questionValidation so that validation can be done when one of the N fields is answered. How to validates the form is written below

 <FormDialog
  title="Test"
  ...
  validationSchema={knockoutQuestions?.questionValidation} 
 />
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!