D
D
Denioo2020-06-22 15:56:11
JavaScript
Denioo, 2020-06-22 15:56:11

How to validate an array of objects in Vuelidate?

I am learning vue and have a question. If there are many identical fields, I save them in an array like this:

array: [
{name: '', title: ''},
{name: '', title: ''},
{name: '', title: ''}
]


How to properly validate an array of objects, and how to pass it to the model.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2020-07-05
Hrebet @hrebet

//
validations: {
  items: {
    required,
    $each: {
      name: {
          required,
      },
      title: {
          required,
      },
    }
  }
}
//

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question