Model validation as functions

The idea is to move validation functionality to external functions
to reduce the coupling to the Model class, so that validation can
possibly be performed on other structures later.