gcanti / tcomb-validation

Validation library based on type combinators
MIT License
400 stars 23 forks source link

Is it possible to validate that a list isn't empty? #39

Closed larsnystrom closed 8 years ago

larsnystrom commented 8 years ago

I can't figure out how to validate that a field should be a non-empty list of structs. Is that possible?

larsnystrom commented 8 years ago

Aha, now I see. Sorry for the ticket, here's the solution if somebody else has this problem:

 const tMyListOfThings = t.subtype(t.list(tMyThing), x => x.length > 0, 'MyListOfThings');