Refactoring validation to include more meaningful error messages