Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

242
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda