Open kwijibo opened 8 years ago
Great idea. union-type allows one to use any validator function. So it should be possible to just define ListOf
and use it like this
var ListOf = type => list => R.all(R.is(type), list)
const Shape = Type({Shape: [ListOf(Point)]})
Unfortunately this still doesn't work:
TypeError: Expecting a function in instanceof check, but got #<Object>
https://tonicdev.com/56d99860c541640d00a08d12/56e9228c007e791100e3d56a
Is ListOf
a common enough modelling requirement that it would be worth adding the function to the library?
I'd be very interested in this type too ! :+1:
It would be useful to be able to define that a property of a type should be a typed list, eg:
Implementation could be something like (assuming the prototype version in the
next
branch)