Split out validation routines for easier testing