Introduce some private helper methods in the DocumentQuery and DocumentValidatorFactory classes.