One of the challenges I'm facing in my JavaScript project is dealing with objects that have two array properties included. As part of my development process, I've decided to utilize the resources provided by the validate.js library.
To illustrate, let's take a look at an example:
var customer = {
name: 'Ted',
address: 'some address',
friends: ['Michelle','Elon'],
purchases: [{ qty:1, goods: 'eggs'}, { qty:2, goods: 'apples'}]
}
Currently, I am seeking to implement validation for the following criteria:
- Ensure that the array of friends only consists of string elements.
- Validate that the array of purchases includes between 1 and 5 entries while also confirming that the quantity (qty) field is always numeric.
I would appreciate guidance on how to accomplish this using validate.js.