I have a java script object that contains two array properties:
I'm using the validate.js library.
For example:
var customer = {
name: 'Ted',
address: 'some address',
friends: ['Michelle','Elon'],
purchases: [{ qty:1, goods: 'eggs'}, { qty:2, goods: 'apples'}]
}
I want to validate the following:
- That the array of friends contains only elements of type string.
- That the array of purchases contains at least 1 purchase but max 5 purchases and that the qty is always numeric.
How can i do that with validate.js?