Fix validation

- fixed validation that broke when introducing error classes
- added a test
Merge pull request #2755 from sebgie/fix-validation

Fix validation