validator: refactor the whole thing

The old code had just a simple function, that does all the stuff, so the
single components could not be tested easily on its own. Not the
validator consists of several smaller methods that could be tested.
test/test_schema: refactor to test validation failures

The test does anymore load all test data and try to validate it. If you
add a new test data you will have to add it to the test, but now you can
also test a validation failure and the expected error message.