Refactoring validation conditional into a method