validate.js validating arrays

867 Views Asked by At

I'm using validate.js in react to validate a form. In parts of the form, fields can be added dynamically. For example like phone numbers.

How do I create validations for each of the fields that are newly created or already exist? This is as far as I got.

phonenumbers: {
 type: 'array'
}
1

There are 1 best solutions below

0
PeonProgrammer On

You could iterate over each phone number and validate. Something like :

this.phoneNumbers.map((item, key) => validate(item, constraints););