[MRG] Input validation refactoring

Refactor input validation to make it more consistent.

Todo
* [x] Tests
* [x] docstrings
I think in this function it is fine. I'm thinking about marking it as private.