refactor validation in config factory