refactored out the validator logic into its own class