guillaumepotier / validator.js

Powerful objects and strings validation in javascript for Node and the browser
http://validatorjs.org
MIT License
255 stars 39 forks source link

Add a is.iterable constraint #64

Open filipefigcorreia opened 7 years ago

filipefigcorreia commented 7 years ago

The is.collection constraint doesn't work for iterators. I suggest a is.iterable constraint is made available for such cases.

ruimarinho commented 7 years ago

Do you want to check if a value is iterable or iterate over its content to assert something? If the latter, I would add support for iterators on the collection() assert.

filipefigcorreia commented 7 years ago

Both seem useful, but the second use-case is the one that interests me the most. Adding support to the collection assert sounds reasonable 👍