Refactor validation code to prepare for the addition of commands.