Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

249
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda