Validate documents during posting

This is to speed things up when posting a large number of docs. We avoid
iterating over the whole collection in advance.