Reputation: 91
options = ['asdasda', 'asdasdas', 'asdasdasafsaafasfasfasfasfasfasasasasasdas', 'asd'];
req.check('options', 'Option must not exceed 30 characters').isLength({max: 30});
Am trying to validate each string in the array options. Is there any way to do it?
Upvotes: 7
Views: 15944
Reputation: 41440
Yes, you must use wildcards for that.
req.check('options.*').isLength({ max: 30 })
Upvotes: 15