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

344
Visualizações
How to validate array of strings so that at least one is not null, in Yup

I have a field which is a array of strings, and depending on this array's length I show inputs. If for example the length of arrray id 5 I show 5 inputs. However by default I have to show 3 inputs, and thats why my default values: [null, null, null]. Now what is the right way to do the validation so it checks the all values, and validate only if at least one is not null?

I know some answers, where they say: yup.array().min(1) is the solution, but in my case the initial value of the field is not an empty array. As I mentioned above there are null values, and I have to check every value of the array

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I don't know yup but in plain javascript you could use some

const invalidData = ['a', null, 'c']
const validData = [1, 2, 3]


const check = data => !data.some(v => v=== null)

console.log(invalidData, check(invalidData))
console.log(validData, check(validData))

about 4 years ago · Juan Pablo Isaza Relatório
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