Refactor file validation

This refactoring simplifies the file validation code and makes it more readable. It also structures it in a way that the scope sepcific code is better isolated, so it can be moved to specific scope classes later.