refactor string validator