Refactor to expose validate function which does not read database