Refactored before_validation hook into smaller methods

The code is a bit longer but I believe the readability improvement should pay off.