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

338
Views
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 answers
Answer question

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 Report
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!